javascript - how can I call a nested global or local jquery variable into html? -
i have problem have tried days no success. help appreciated.
i phone call variable nested jquery html. variable have called name "problem". have tried create global when update locally within function
$(".dropdown dd ul li a").click(function() { }
the changes remain local. how can this? give thanks you. nb/i have updated pasting whole function. found function online , modified performa select function both image , text. know selection facebook when happens can alter signup page facebook page,
<span =email>
the part above helps me know if email or other social media site. on running alert(text)
displays
<span =email=""><img class="flag flagvisibility" src="media/email_icon.png" alt="" style="margin-bottom:0px" height="30" width="30" align="left""> email</span>
and use
var n1 = text.indexof("=") + 1; var n2 = text.indexof("=", n1);// or utilize c=text.slice(text.indexof("=")+1, text.indexof("=", text.indexof("=")+1)) n3 = text.slice(n1, n2) problem[0] = text.slice(n1, n2)
to 1st , 2nd indicies of equal sign "=" , can extract if email or other social media sites. hope helps
here whole
</style> <script type="text/javascript"> var problem =[] $(document).ready(function() { $(".dropdown img.flag").addclass("flagvisibility"); $(".dropdown dt a").click(function() { $(".dropdown dd ul").toggle(); homecoming false; //this of import part }); $(".dropdown dd ul li a").click(function() { var text = $(this).html(); $(".dropdown dt span").html(text); $(".dropdown dd ul").hide(); //$("#result").html(text); //$("#result").html("selected value is: " + getselectedvalue("sample")); $("#result").html("selected value is: " + text); var n1 = text.indexof("=") + 1; var n2 = text.indexof("=", n1);// or utilize c=text.slice(text.indexof("=")+1, text.indexof("=", text.indexof("=")+1)) n3 = text.slice(n1, n2) problem[0] = text.slice(n1, n2) //return false; //this of import part }) function getselectedvalue(id) { homecoming $("#" + id).find("dt span.value").html(); } $(document).bind('click', function(e) { var $clicked = $(e.target); if (! $clicked.parents().hasclass("dropdown")) $(".dropdown dd ul").hide(); }); $("#flagswitcher").click(function() { $(".dropdown img.flag").toggleclass("flagvisibility"); }); }); </script> <dl id="sample" class="dropdown"> <dt style="vertical-align:middle"><a href="#"><span ><img class="flag" src="media/email_icon.png" alt="" width="30" height="30" align=left" style="margin-bottom:0px"/> email</span></a></dt> <dd> <ul> <!--the utilize of names email, face book in span dirty steps in javascript above .indexof("=")--> <li><a href="#"><span =email><img class="flag" src="media/email_icon.png" alt="" width="30" height="30" align=left" style="margin-bottom:0px" /> email</span></a></li> <li><a href="#"><span =facebook><img class="flag" src="media/facebook_icon.png" alt="" width="30" height="30" align=left" style="margin-bottom:0px" /> facebook</span></a></li> <li><a href="#"><span =twitter><img class="flag" src="media/twitter_icon.png" alt="" width="30" height="30" align=left" style="margin-bottom:0px" /> twitter</span></a></li> <li><a href="#"><span =linkedin><img class="flag" src="media/linkedin_icon.png" alt="" width="30" height="30" align=left" style="margin-bottom:0px" /> linkedin</span></a></li> </ul> </dd> </dl> <span id="result">
i think issue caused because you're not preventing hyperlinks default action happening. need either utilize return false;
or event.preventdefault();
stop link posting back.
var problem = []; $(document).ready(function() { $(".dropdown img.flag").addclass("flagvisibility"); $(".dropdown dt a").click(function() { $(".dropdown dd ul").toggle(); homecoming false; //this of import part }); $(".dropdown dd ul li a").click(function() { var text = $(this).html(); $(".dropdown dt span").html(text); $(".dropdown dd ul").hide(); $("#result").html("selected value is: " + text); var n1 = text.indexof("=") + 1, n2 = text.indexof("=", n1); n3 = text.slice(n1,n2); problem = text.slice(n1,n2); homecoming false; //this of import part } });
also jquery ready event not formed:
$(document).ready(function() { }); // missing closing bracket.
javascript jquery html
No comments:
Post a Comment