Get element from which onclick function is called

前端 未结 8 1028
野趣味
野趣味 2021-01-18 03:59

I have a button with a onclick attribute which is pointing to the function test().


<         


        
8条回答
  •  长情又很酷
    2021-01-18 04:55

    	function test(button)
    	{
    	    var button_name = button.getAttribute('name');
    	    console.log("Im button "+ button_name);
    	}
    	
    	
    	

提交回复
热议问题