html单击事件this
㈠ JS问题~~请高手们赐教!如何将onclick=“this.value=''”改写到JS中,在html中不出现JS事件
把这个代码放在html的head处
<script type="text/javascript">
window.onload=function(){
var o=document.getElementById('input的id');//自己在html中加上id
o.onfocus=function(){this.value='';}
}
</script>
㈡ html源文件中onclick="this.href=SendComplexUrl()"。其中为什么要加this.href=
表示!只有这个层才执行
SendComplexUrl()"
函数!
㈢ 在html事件属性中调js函数, this问题
this为当前的Object。在你的函数
function demo() {
alert(this.id)
this.value = a++;
}
中this指向的是demo而非触发它的input
所以
this要传递的。
不知你是否想要下面的
<body>
<input type="button" id="aButton" value="A" onclick="demo(this)" />
<input type="button" id="bButton" value="B" />
<script type="text/javascript">
var a=1;
function demo(t) {
alert(t.id)
t.value = a++;
}
document.getElementById("bButton").onclick = new Function("demo(this)");
var button_a = document.getElementById("aButton");
alert(button_a.onclick);
var button_b = document.getElementById("bButton");
alert(button_b.onclick);
</script>
</body>
㈣ html 给某个标签添加点击事件,为什么this 指向的是window
发一下代码哦 事件冒泡后就会指向window 具体问题具体分析
㈤ 这个html网页的javascript点击事件怎么写
<script type="text/javascript">
function getValue2()
{
var x=document.getElementById("pid")
alert(x.innerHTML)
}
</script>
<p id="pid" onclick="getValue2()">点击标来题,会自提示出它的值。</p>
这样就可以了
㈥ html js函数传的this是什么意思
意思就是把你触发事件的这个控件传递过去.
<input type="button" id="tianjia" value="保 存" class="btn1" onClick="nullCheck(this)"/>
function nullCheck(obj){
obj.value;//这样就得到控件value了
}
㈦ javascript的html事件中this的问题
this是指本元素
每一个HTML标签,都会在DOM树下产生一个元素节点,这个this是写在哪个标签内,那么show函数里面的参数就是哪个标签所产生的元素的id,如
<input type="button" id="我是button1" onclick="alert(this.id)" value="按我测试"/>
<input type="button" id="我是button2" onclick="alert(this.id)" value="按我测试"/>
㈧ HTML中onClick="chg(this.status)什么意思
鼠标点击时执行chg(this.status)这个事件。 东莞汇鑫--企业邮箱,网站建设
㈨ html点击事件
已经上传附件,下载附件测试吧
㈩ jquery onclick=""事件怎么传一个this对象和一个值进去呢
<body>
<aonclick="shanchu('1',this)">点击</a>
</body>
<scripttype="text/javascript">
functionshanchu(a,obj){
alert(a);
alert($(obj).html());
}
</script>
函数传入this对象,这样'this'会被当成字符串。