Prototype select last input
<form id="file_upload_form"> ...
<input type="submit" value="Submit" name="submit">
</form>
Just need a alert box to appear on clicking the input. I'm a jQuery man so not sure how to target the DOM with prototype. I can't edit the HTML 开发者_如何学Pythonotherwise I would just give it an ID.
Must be easy but can't figure it out.
$$('#file_upload_form > input[type="submit"]').first().observe('click',
function()
{
alert('Hello');
});
$$
is Prototype's Selector engine shortcut. You can use any CSS selector to pick up the elements you are interested in. first()
just grabs the first element returned, and observe()
is the standard way to subscribe to events in Prototype.
Edit: Wrong quote marks
精彩评论