trying to do something pretty obvious really but its kinda not making any sense / not working for me …
The idea is simple, when the document is loaded $(document).ready() get all input elements that have attribute type=”text” on them and add the css class “textbox” …
<script type="text/javascript">
$(document).ready(function () {
var textboxes = $(":input [type = 'text']");
textboxes.each().addClass("textbox");
});
</script>
Any ideas why this doesn’t work ?? …
EDIT:
Wow .. still have a lot to learn about jquery-isms … starting to love jquery though 🙂 it’s simplicity really does the trick.
No need for the colon before the element
input.$("input[type='text']")will reference all elements so no need for aneach()