javascript - DOM element doesn't display -
i new in javascript , trying test next code
<html> <head> <script src="jquery/jquery.min.js"> </head> <body> <input type="button" value="click button"> <script type="text/javascript"> $(function(){ $('input')[0].on('click',function(){ alert('button clicked'); }); }); </script> </body> </html> but when open html file in browser button doesn't display
script tags require closing tag, you've omitted:
<script src="jquery/jquery.min.js"></script> ^ close by leaving open, browser treating after script tag script content.
also $('input')[0] isn't right. getting dom element of input, has no jquery wrapper , no .on() function. if trying match first input then:
$('input').first().on('click',function(){ javascript jquery html
No comments:
Post a Comment