I try to pass a page within the main page, and a page that want to pass it contains the tag ,When it is pressed working to pass another page within the main page.
I've put jquery on the main page, but it did not work, but I put it on the tag page, But it worked on the first row only. This jquery when press tag
$( "#update_range" ).click(function() {
var testing2 = this.name;
$.ajax({
type: "POST",
url: "update_form.php",
data: { testing1:testing2 },
success: function(data) {
$("#inner_content").append(data+"<br/>");
},
});
});
And this is tag ,I have many of them in the table and this is one of them, they are have same id :
<td><a href="#update" id="update_range" name="<?php echo $row1['id_testing']; ?>">Update Test</a></td>
答案 0 :(得分:1)
"#update_range"
是ID selector。文档中的ID must be unique。
据推测,您已经为每一行提供了相同的ID,这是无效的HTML(使用validator)并导致JavaScript只找到具有该ID的第一个元素。
使用class selector(以.
开头)和class attribute代替。
name
元素上的<a>
属性已过时。您正在使用id
属性来使用它(并且由于您实际上并未尝试在任何地方进行链接,因此您应该使用<button>
而不是<a>
太)。