Javascript 如何在没有标记ID的情况下设置此元素输入';s
5输入类型,无标签ID;如果我点击输入提示命令将出现,并说输入您的姓名?;输入名称后,如何对jquery“This.value=person”进行编码 请帮忙。他们没有在可单击的输入上输入person=提示。只需使用.val()函数设置当前元素值属性Javascript 如何在没有标记ID的情况下设置此元素输入';s,javascript,jquery,dom,Javascript,Jquery,Dom,5输入类型,无标签ID;如果我点击输入提示命令将出现,并说输入您的姓名?;输入名称后,如何对jquery“This.value=person”进行编码 请帮忙。他们没有在可单击的输入上输入person=提示。只需使用.val()函数设置当前元素值属性 $(this).val(person); 然后删除不需要的,这里稍微修改一下 $(document).ready(function(e){ $("input").click(function(){ var that=$(
$(this).val(person);
然后删除不需要的
,这里稍微修改一下
$(document).ready(function(e){
$("input").click(function(){
var that=$(this);//create a reference
var person = prompt("Please enter your name:");
if (person) { //as per @Roko C.Buljan's suggestion
that.val(person); //assign its val
//or even $(this) is fine
that.css("background-color","green");//as per @Roko C.Buljan's suggestion
//You can move it here in case cancel is clicked
}
});
});
$(document).ready(function(e){
$("input").click(function(){
var that=$(this);//create a reference
var person = prompt("Please enter your name:");
if (person) { //as per @Roko C.Buljan's suggestion
that.val(person); //assign its val
//or even $(this) is fine
that.css("background-color","green");//as per @Roko C.Buljan's suggestion
//You can move it here in case cancel is clicked
}
});
});
正如@Roko C.Buljan所说的,是的,不是<代码>不能有结束标记。
?输入是无效元素之一,不能有结束标记。(两者都不能包含其他子元素)谢谢大家$(本)val(人);让我的一天快乐:)
$(document).ready(function(e){
$("input").click(function(){
var that=$(this);//create a reference
var person = prompt("Please enter your name:");
if (person) { //as per @Roko C.Buljan's suggestion
that.val(person); //assign its val
//or even $(this) is fine
that.css("background-color","green");//as per @Roko C.Buljan's suggestion
//You can move it here in case cancel is clicked
}
});
});