【发布时间】:2013-02-06 03:46:09
【问题描述】:
如何使用相同的脚本发送我的 div 的 ID! 就像当用户发送表单时,我也想发送 de div 的 id。 我想为我的图片上传系统制作 cmetsystem。
$(function() {
$(".submit").click(function() {
var name = $("#name").val();
var email = $("#email").val();
var comment = $("#comment").val();
var dataString = 'name='+ name + '&email=' + email + '&comment=' + comment;
if( comment=='')
{
alert('Please Give Valide Details');
}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle"> <span class="loading">Loading Comment...</span>');
$.ajax({
type: "POST",
url: "piccommentajax.php?id=<? echo $idcom ?>",
data: dataString,
cache: false,
success: function(html){
$("ol#show").append(html);
$("ol#show li:first").fadeIn("slow");
document.getElementById('comment').value='';
$("#name").focus();
$("#flash").hide();
}
});
}
return false;
});
});
【问题讨论】:
-
div 的 id 是什么意思?你是在说 div 的 html id 还是什么?
-
你可以使用
$(div).attr('id')获取一个div id。 -
是这样内容
-
为什么随机的非 jQuery 调用?
document.getElementById('comment').value=''为什么不$('#comment').val('')?