js this関数の呼び出しは、再度id、nameまたは署名を取得する必要はありません。

807 ワード

thisはあなたが今実行しているjsで逮捕されたノードです。このようにjsではdocument.getElementなどの書き方でid、nameやサインを取得しなくてもいいです。普通はobjで代用します。
 
<input type="button" id="tianjia" value=" " class="btn1" onClick="nullCheck(this)"/>
<script>
function nullCheck(obj)
{
......//
}
</script>

<input type="checkbox" name='agentType' id="exclusiveAgenter" value="exclusive" onchange="clickAgenter(this)">

function clickAgenter(obj){
if($(obj).attr("checked")=="checked"){
$("[name='agentType']").removeAttr("checked");//
$(obj).attr("checked","checked")
}
}