Jquery: Tips ‘n’ Tricks
Jquery and browser support. well both of them nearly don’t work all together. I just got stuck somewhere i found a weird solution Just remove an @ symbol did that.
While working on a project i was stuck on a jquery code that wasn’t working on IE8(now free for Xp users).
I was working with two set if radio buttons. the problem was with the second radio button set.
The code that did not work was this below.
<tr> <td> Have you used any other names in the past eight years? </td> <td> <input type="radio" name="ot" value="1">yes <input type="radio" name="ot" value="2">No </td> <script type="text/javascript"> $j('[name=ot]').click(function() { var ot = $j("input[@name='ot']:checked").val(); if(ot == 1) { $j("#odrnames").fadeIn("slow"); } else { $j("#odrnames").fadeOut("slow"); } }); </script> </td> </tr> <tr id="odrnames" style="display: none;"> <td> Other Names </td> <td> <input type="text" id="txt" name="otherNam"> *Seperate By commas </td> </tr> <tr> <td> Filing Status: </td> <td> <input type="radio" name="fs" value="1">Single <input type="radio" name="fs" value="2">Joint </td> <script type="text/javascript"> $j('[name=fs]').click(function() { var person = $j("input[@name='fs']:checked").val(); //alert(person); if(person == 2) { $j("#joint0").fadeIn("slow"); } else { $j("#joint0").fadeOut("slow"); } }); </script> </tr> <div> <tr id="joint0" style="display: none;"> <td> Full Name of Spouse: </td> <td> <input type="text" id="txt" name="sname"> </td> </tr>
I just changes the jquery codes from
var person = $j("input[@name='fs']:checked").val();
To
var person = $j("input[name='fs']:checked").val();
A small code for developers the IE8 users to be in compatible mode.
try this
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
So this was the solution i found. Please do comment if you have better ideas or face any problem.
