jquery find input:hidden error in safari
I'm trying to implement a feature where a user can click on a row i.e., <tr>
, and it'll go to a specific URL.
Here's my HTML and Jquery code:
<tbody>
开发者_StackOverflow中文版 <tr>
<input class="threadid_c" id="threadID" name="threadID" type="hidden" value="MzAwMTYwLDMwMDM3Miw=" />
<td>
...
</tr>
<tr>
<input class="threadid_c" id="threadID" name="threadID" type="hidden" value="MzAwMzcyLDMwMDM4MCw=" />
<td>
....
$('#datatable tr').click(function() {
var x = $(this).find("input:hidden");
var url = "/User/Ping/" + x.val();
location.href = url;
});
This works fine in Chrome, Firefox, and IE. But in Safari, x.val()
returns undefined
.
I looked in Safari's JavaScript console, I see this message:
<input> is not allowed inside <tr>. Inserting <input> before the <table> instead.
Not sure if that's related to the problem. Any suggestions?
You can't have a <input>
as a direct <tr>
child just like it says, just tuck it inside the first <td>
instead, like this:
<tr>
<td>
<input class="threadid_c" name="threadID" type="hidden" value="MzAwMzcyLDMwMDM4MCw=" />
....
Also remove the id
attribute since it's repeated...they should be unique in the page.
精彩评论