如何用js为label标签添加for属性

如何用js为label标签添加for属性,第1张

var obj=document.getElementById("你的label的id")

obj.setAttribute("丛铅物for"渗液激绝,"for对应的值")

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/橘猛/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"圆亮桥>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>无标题文档</title>

<script language="javascript">

function addid(obj,idname){

obj.id=idname

}

function showidname(){

alert(document.getElementById("current"键乎).id)

}

</script>

</head>

<body>

<a href="#" onclick="addid(this,'current')">测试测试</a><br/>

<a href="#" onclick="showidname()">看看有没有加上</a>

</body>

</html>

你好,这样写既可: 希望采运敏纳!!!!

$(function(){

var title_text

$('#this_post_tags a').each(function(){

 title_text= "点击查看更多与【卜掘" + $(this).text() + "】相关的内容"

  $(this).attr('型悄核title',title_text)

})

})


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/bake/11987310.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存