¡@

Home 

2014/10/16 ¤W¤È 12:03:08

jquery Programming Glossary: el.attr

Simulate native click

http://stackoverflow.com/questions/1786377/simulate-native-click

I've got so far var el 'a#my_special_link' var onClick el.attr 'onclick' Hack to capture the event object var ev_reference.. if ev_reference.isDefaultPrevented window.location el.attr 'href' Any suggestions for improvement are welcome. PS Yes it's..

What useful custom jQuery selectors have you written?

http://stackoverflow.com/questions/1940574/what-useful-custom-jquery-selectors-have-you-written

' ' textboxEmpty function el var el el return el.val el.attr type text And to call alert textboxEmpty .length I was wondering..

Jquery - save class state for multiple div #'s to a cookie?

http://stackoverflow.com/questions/2101417/jquery-save-class-state-for-multiple-div-s-to-a-cookie

el Update the Cookie function updateCookie el var indx el.attr 'id' var tmp hidden.getUnique if el.is ' hidden' add index of..

dynamically add remove rows in table using jquery

http://stackoverflow.com/questions/2228772/dynamically-add-remove-rows-in-table-using-jquery

el.closest 'tr' .clone true .prependTo el.closest 'table' el.attr value Delete row function this .closest 'tr' .remove table..

Slider with buttons. How to improve?

http://stackoverflow.com/questions/2834004/slider-with-buttons-how-to-improve

leftOffsetInt parseInt this.css 'marginLeft' .slice 0 2 if el.attr 'class' 'bttR' leftOffsetStr leftOffsetInt offsetStep .toString.. leftOffsetInt offsetStep .toString 'px' else if el.attr 'class' 'bttL' leftOffsetStr leftOffsetInt offsetStep .toString..

iPad/iPhone hover problem causes the user to double click a link

http://stackoverflow.com/questions/3038898/ipad-iphone-hover-problem-causes-the-user-to-double-click-a-link

'a' .on 'click touchend' function e var el this var link el.attr 'href' window.location link The idea is that Mobile WebKit fires..

jQuery UI Dialog instead of alert() for Rails 3 data-confirm attribute

http://stackoverflow.com/questions/4421072/jquery-ui-dialog-instead-of-alert-for-rails-3-data-confirm-attribute

var el this if el.triggerAndReturn 'confirm' if confirm el.attr 'data confirm' return false and triggerAndReturn function..

Hiding Options of a Select with JQuery

http://stackoverflow.com/questions/4699410/hiding-options-of-a-select-with-jquery

el.data 'status' 'enabled' _this.items.push attribute el.attr _this.opts.attribute el el disable function key .each this.items..

Registration form validation

http://stackoverflow.com/questions/7059441/registration-form-validation

el.hasClass 'default' el.removeClass 'default' .val '' if el.attr 'id' 'dob' this .mask '99.99.9999' placeholder ' ' 'input'.. ' ' 'input' .live 'blur' function var el this var name el.attr 'name' Really we only want to do anything if the field is empty..

Simulate native click

http://stackoverflow.com/questions/1786377/simulate-native-click

prevented the default change the location. This is what I've got so far var el 'a#my_special_link' var onClick el.attr 'onclick' Hack to capture the event object var ev_reference var ev_capture function ev ev_reference ev el.bind 'click' ev_capture.. onClick 'function' el.unbind 'click' onClick Redirect if necessary if ev_reference.isDefaultPrevented window.location el.attr 'href' Any suggestions for improvement are welcome. PS Yes it's just how a regular link would work except you can do some..

What useful custom jQuery selectors have you written?

http://stackoverflow.com/questions/1940574/what-useful-custom-jquery-selectors-have-you-written

text boxes that are empty document .ready function .extend .expr ' ' textboxEmpty function el var el el return el.val el.attr type text And to call alert textboxEmpty .length I was wondering really if anyone else had some useful examples of custom..

Jquery - save class state for multiple div #'s to a cookie?

http://stackoverflow.com/questions/2101417/jquery-save-class-state-for-multiple-div-s-to-a-cookie

'add' var el div# this .attr 'name' el.toggle updateCookie el Update the Cookie function updateCookie el var indx el.attr 'id' var tmp hidden.getUnique if el.is ' hidden' add index of widget to hidden list tmp.push indx else remove element id..

dynamically add remove rows in table using jquery

http://stackoverflow.com/questions/2228772/dynamically-add-remove-rows-in-table-using-jquery

input type 'button' .AddRow .toggle function var el this el.closest 'tr' .clone true .prependTo el.closest 'table' el.attr value Delete row function this .closest 'tr' .remove table id dataTable border 1 thead tr th Name th th Value th tr..

Slider with buttons. How to improve?

http://stackoverflow.com/questions/2834004/slider-with-buttons-how-to-improve

function el if this.data 'loop' true var leftOffsetStr leftOffsetInt parseInt this.css 'marginLeft' .slice 0 2 if el.attr 'class' 'bttR' leftOffsetStr leftOffsetInt offsetStep .toString 'px' else if el.attr 'class' 'bttL' leftOffsetStr leftOffsetInt.. 'marginLeft' .slice 0 2 if el.attr 'class' 'bttR' leftOffsetStr leftOffsetInt offsetStep .toString 'px' else if el.attr 'class' 'bttL' leftOffsetStr leftOffsetInt offsetStep .toString 'px' this.animate marginLeft leftOffsetStr animateTime function..

iPad/iPhone hover problem causes the user to double click a link

http://stackoverflow.com/questions/3038898/ipad-iphone-hover-problem-causes-the-user-to-double-click-a-link

events this could work assuming you are in a jQuery setting. 'a' .on 'click touchend' function e var el this var link el.attr 'href' window.location link The idea is that Mobile WebKit fires a touchend event at the end of a tap so we listen for that..

jQuery UI Dialog instead of alert() for Rails 3 data-confirm attribute

http://stackoverflow.com/questions/4421072/jquery-ui-dialog-instead-of-alert-for-rails-3-data-confirm-attribute

data confirm input data confirm ' 'click.rails' function var el this if el.triggerAndReturn 'confirm' if confirm el.attr 'data confirm' return false and triggerAndReturn function name data var event new .Event name this.trigger event data..

Hiding Options of a Select with JQuery

http://stackoverflow.com/questions/4699410/hiding-options-of-a-select-with-jquery

this 'option' this. el .each function i obj var el obj el.data 'status' 'enabled' _this.items.push attribute el.attr _this.opts.attribute el el disable function key .each this.items function i item if item.attribute key item. el.remove..

Registration form validation

http://stackoverflow.com/questions/7059441/registration-form-validation

of Birth' 'input' .live 'focus' function var el this if el.hasClass 'default' el.removeClass 'default' .val '' if el.attr 'id' 'dob' this .mask '99.99.9999' placeholder ' ' 'input' .live 'blur' function var el this var name el.attr 'name' Really.. '' if el.attr 'id' 'dob' this .mask '99.99.9999' placeholder ' ' 'input' .live 'blur' function var el this var name el.attr 'name' Really we only want to do anything if the field is empty if el.val .match ^ s . To get our default style back we'll..