javascript - Get element from inside function -


good morning in timezone.

i had code in html page

<span id="x>     <div onclick="$(this).applyfancybox({         trigger: !$.browser.msie,          target: (event.srcelement || event.target)     }); return false;"> 

and changing code

<span id="x">     <div> </span>  <script> ... $(document).ready (function () {      $("#x div")         .click(function(){             this.applyfancybox({                 trigger: !$.browser.msie,                  target: (event.srcelement || event.target)             }); return false;         }); } ... </script> 

this not working because think not pointing div element, how can fix ?

thanks in advance best regards

try changing this $(this)

this javascript object , $(this) jquery object

so final code like

$(document).ready (function () {     $("#x div")         .click(function(){             $(this).applyfancybox({                 trigger: !$.browser.msie,                  target: (event.srcelement || event.target)             }); return false;         }); } 

by way , $.browser.msie deprecated 1.3 , removed in 1.9


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -