我有按钮和div,并且在每个部分中我都有相同的ID我想要获得按钮的ID并使用它来刷新div html.how应该写*部分吗?用jquery指定div id
$(function() {
$(".button").click(function(){
var id=$(this).attr('id');
var dataString = 'id='+ id ;
$.ajax({
type: "POST",
url: "download_number.php",
data: dataString,
cache: false,
success: function(html)
{
*********I HAVE PROBLEM HERE**************
$('how to get the id of the div from var id of button above?').html(html);
}
});
});
});
事业部:
Downloaded:<div id="<?php echo $id; ?>" ><?php echo $downloadcount;?></div>
按钮:
<input type = "button" value="Download" class="button" id="<?php echo $id; ?>" name="dl">
如果我得到的类将更新整个的div我想只更新realted到按钮
股利
有效的HTML不会重复使用ID's ...最好将它作为类而不是ID,元素可以处理多个类。 – JKirchartz
ID必须是唯一的。 – undefined
如果我上课,它会更新整个div,但我只想更新与该按钮相关的div – Nickool