How to get asp.net client id at external javascript file

前端 未结 5 1532
暖寄归人
暖寄归人 2020-11-28 12:58

When I use embedded javascript functions I can get client id of elements with this code:

document.getElementById(\'<%=buttonXXX         


        
5条回答
  •  爱一瞬间的悲伤
    2020-11-28 13:41

    You could use a class selector. jquery might greatly simplify your life here. So you could apply a special class to the control:

    
    

    and in your external javascript file once the DOM is ready you could reference the button using a class selector:

    $(function() {
        var fooButton = $('.foo');
    });
    

提交回复
热议问题