Update JavaScript variable in jQuery -
please can on how value jquery javascript?
var mytitle = "abctitle"; function showtitle(myvar) { mytitle = myvar; alert(mytitle); } $(document).ready(function() { alert(mytitle); //i alert "abctitle" mytitle = "changed"; });
how can value set in query outside call in jscript?
your code right, , supposed to
var mytitle = "abctitle"; var e = document.getelementbyid('show'); e.onclick = showtitle; function showtitle(){ alert(mytitle); } $(document).ready(function() { alert(mytitle); //i alert "abctitle" mytitle = "changed"; });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <button id="show">click me</button>
this alert mytitle new title, showing 'jquery' can access javascript variables , change them.
Comments
Post a Comment