Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- before: -->
- <a href="#" onclick="alert('Hello world!'); return false;">Click Here</a>
- <!-- after: -->
- <a href="#" id="myAlert" data-message="Hello from UJS">Click Here</a>
- <script type="text/javascript">
- $(function() { // in jQuery, $() appends an onLoad handler to document
- $('#myAlert').click(function () { // adds an onClick handler to #myAlert
- alert('Hello, world!'); return false;
- })
- // we could add other elements' event handlers here
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement