Is it a good or bad practice to use jQuery statements in plain javascript functions outside of ready? If not what is the correct way?
//** End ready **//
function doSomething() {
selectedClickBoxIndex = parseInt( jQuery('.' + clickBoxOnClass ).attr('value') );
// Javascript code
}
nothing wrong. When you include the jquery file, you're expanding your functionality, free to use wherever you want
There is nothing wrong with that. jQuery is just a Javascript library, there is no strict separation between them.
You might want to use the function val
, though:
function doSomething() {
selectedClickBoxIndex = parseInt( jQuery('.' + clickBoxOnClass ).val() );
// Javascript code
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With