javascript - Toggle issue using input value as id -
I use jQuery .toggle ()
to create three divs. The unique ID and decision in the division, which is toggled Digg, is based on the three radio buttons that have been selected. The three radio buttons have a value that corresponds to the ID of the device. Therefore, if a person clicks on 1 radio, the division should be toggled with id cMB_0292_A07.m1
.
Although I am not getting any answers and there is no report in it, I have tried that any error in debugger is wrong?
& lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; Function shadow (obje) {var n = obj.name; Var v = $ ("Input: radio [name = '+ n +"']: checked "). Val (); Warning (v); $ (" # "+ v) Toggle ();} & Lt; / script> gt; & gt; & gt; Body & gt; & lt; input name = "cMB_0292_A07" value = "cMB_0292_A07.m1" onclick = "showdiv (this);" type = " Input name = "cMB_0292_A07" value = "cMB_0292_A07.0" onclick = "showdiv (this);" type = "radio" & gt; 0 & lt; input name = "cMB_0292_A07" Value = "cMB_0292_A07.p1" onclick = "showdiv (this);" type = "radio" & gt; +1 & lt; div id = "cMB_0292_A07.m1" style = "display: none" & gt; minus1 & Lt; / div & gt; div id = "cMB_0292_A07.0" style = "display: none" & gt; zero & lt; / div & gt; & lt; div Id = "cMB_0292_A07.p1" style = "display: none" & gt; plus 1 & lt; / div & gt; & lt; / body & gt; & lt; / html & gt;
>This is actually a two part issue
the most First, you should not not << em>
.
in the IDSecond, jQuery is seeing:
$ ('for example
A child of
class . You can fix this, either you can remove the duration within your ID Or regex selector
[id = ""]
.$ ('[id =' + V + '"]'). Toggle ();
onClick events is better to isolate your business logic and amp; presentation logic
.on ('click', function) {});
events!
Comments
Post a Comment