How can i trigger click and get the value 100? (trigger click is working but alert does not show that value 100).
// Manually clicked
$('.clickhere').live("click", function(){
$(this).parent().parent().parent().parent().parent().parent().parent().find('.triggerclick').trigger('click');
});
// Trigger click
$(".triggerclick").live("click", function() {
var root = $(this);
var id = root.find(".test").text(); // should show 100
alert(id);
return false;
});
<!-- based on this structure -->
<div class="triggerclick">
<img class="left"/>
<div class="left">
<div> </div>
<div> </div>
<div>
<ul>
<li>
<a>
<span class="clickhere">Main Click is here</span>
</a>
</li>
</ul>
</div>
<div> </div>
<div> </div>
</div>
<code class="test">100</code>
</div>
Your example seems to be working just fine but why this?
When you can do:
live()is deprecated,on()is the new guy.