开发者

Prototype select last input

开发者 https://www.devze.com 2023-02-07 14:00 出处:网络
<form id=\"file_upload_form\"> ... <input type=\"submit\" value=\"Submit\" name=\"submit\">
<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

0

精彩评论

暂无评论...
验证码 换一张
取 消