[英]Trigger the share button click on clicking another button
I have the following code 我有以下代码
<div class="event_starpline">
<div style="width:71%;float:left;">
<div id="starpline_timestamp_location"
title="Location : Chennai">Chennai</div>
<div id="starpline_timestamp_posted"
title="Posted Jan 30, 2013"
style="margin-left:10px;">
<acronym title="30 January 2013 @ 8:58am">471 days ago</acronym>
</div>
<div id="starpline_timestamp_refer"
title="Refer your friends"
style="margin-left:10px;">
<a href="#">Refer your friends</a>
</div>
</div>
<div class="starpline_right" style="width:28%;">
<div style="float:left; width:108px; padding-top:5px;">
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style addthis_20x20_style"
addthis:url="http://10.0.1.22/firstplanet/fpin/dev/pg/ad/read/39342/community-developer-4"
addthis:title="Community developer 4"
addthis:description="Job" description="">
<a class="addthis_button_twitter addthis_button_preferred_2 at300b"
title="Tweet" href="#">
<span class=" at300bs at15nc at15t_twitter">
<span class="at_a11y">Share on twitter</span>
</span>
</a>
<a class="addthis_button_facebook addthis_button_preferred_1 at300b" title="Facebook" href="#">
<span class=" at300bs at15nc at15t_facebook">
<span class="at_a11y">Share on facebook</span>
</span>
</a>
<a class="addthis_button_email addthis_button_preferred_3 at300b"
target="_blank" title="Email" href="#">
<span class=" at300bs at15nc at15t_email">
<span class="at_a11y">Share on email</span>
</span>
</a>
<div class="atclear"></div>
</div>
<script type="text/javascript">
var addthis_config = {
"data_track_addressbar": true
};
</script>
<script type="text/javascript"
src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-510b54196b4318c8"></script>
<div id="_atssh"
style="visibility: hidden; height: 1px; width: 1px; position: absolute; z-index: 100000;">
<iframe id="_atssh679"
title="AddThis utility frame"
src="//ct1.addthis.com/static/r07/sh158.html#iit=1400219038582&tmr=load%3D1400219036211%26core%3D1400219036863%26main%3D1400219038575%26ifr%3D1400219038590&cb=0&cdn=0&chr=UTF-8&kw=open%20source%2Cfirst%20planet%2Cfirstplanet%2Cjob%20seekers%2Cunemployment%2Cfreshers%2Crecruitment%2Ctraining%2Cjobs%2Cinformation%20technology%2CIT%20Job%2Cwalkins%2Csatori%2Clamp%2Cdotnet%2Cjava%2Cchennai%2Canna%20salai%2Ctechnologies&ab=-&dh=10.0.1.22&dr=http%3A%2F%2F10.0.1.22%2Ffirstplanet%2Ffpin%2Fdev%2Fpg%2Fsearch%2F%3Ftag%3Da%26entity_subtype%3Dad%26entity_type%3Dobject%26search_type%3Dentities&du=http%3A%2F%2F10.0.1.22%2Ffirstplanet%2Ffpin%2Fdev%2Fpg%2Fad%2Fall%2F&dt=First%20Planet%3A%20Job%20posts&dbg=0&md=0&cap=tc%3D0%26ab%3D1&inst=1&vcl=1&jsl=1&prod=undefined&lng=en-US&ogt=&pc=men&pub=ra-510b54196b4318c8&ssl=0&sid=5375a59c9ed1ff23&srpl=1&srcs=1&srd=1&srf=1&srx=1&ver=300&xck=0&xtr=0&og=&aa=0&csi=undefined&rev=1399981304&ct=1&xld=1&xd=1&fcu=U3WlnIGSxBl"
style="height: 1px; width: 1px; position: absolute; z-index: 100000; border: 0px; left: 0px; top: 0px;">
</iframe>
</div>
<script type="text/javascript"
src="http://ct1.addthis.com/static/r07/core131.js"></script>
<!-- AddThis Button END -->
In this i want when i will click Refer your friends
it will trigger addthis_button_email
addthis_button_preferred_3 at300b
& it will show a pop up. 在这种情况下,当我单击“推荐
Refer your friends
,它将触发addthis_button_email
addthis_button_preferred_3 at300b
并显示一个弹出窗口。
I tried below code 我尝试下面的代码
jQuery("div#starpline_timestamp_refer").click(function(){
// trigger second button
jQuery(".addthis_button_email addthis_button_preferred_3 at300b").click()
return false;
});
Okay some how its triggered now. 好的,现在它是如何触发的。
Actually its a list of items. 实际上是项目清单。 I have shown one item only.
我只显示了一项。 So every time if i click it takes last item property.
因此,每当我单击它时,它就需要最后一个属性。 Can we select properly one item from the list.
我们可以从列表中正确选择一项吗? How can we do that ?
我们该怎么做?
You are missing the class selector [dot] and remove the space between selector : 您缺少类选择器[dot]并删除选择器之间的空格:
jQuery(".addthis_button_email.addthis_button_preferred_3.at300b").click()
// here ^^ and here ^^
I think the function you are looking for is "trigger()" ( http://api.jquery.com/trigger/ ) 我认为您正在寻找的功能是“ trigger()”( http://api.jquery.com/trigger/ )
It can be used to trigger events on a chosen element. 它可用于触发所选元素上的事件。
jQuery("div#starpline_timestamp_refer").click(function(){
// trigger second button
jQuery(".addthis_button_email addthis_button_preferred_3 .at300b").trigger("click");
return false;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.