I’m making a little script right now and one of the inputs for an arg of the main function is an element. In order to make sure that raw JS works for this stuff I’m doing theelement.value to get the variable’s value. Unfortunately, that doesn’t work if thelement is a jquery function, like $('#foo'). Some other reasons I need this kind of compatibility is that I need access to theelement.style, once again something jquery doesn’t support. I know there are jquery workarounds for these (.css(), .val() etc.) but if I use those, then regular js inputs (document.getElementbyId('foo')) won’t work. Is there any way to use one “property” and make it universal against all inputs of elements (including stuff from libraries like prototype and Dojo)?
I’m making a little script right now and one of the inputs for an
Share
No it is not possible to make everything universal.
If you want to work on DOM elements, the input needs to be DOM elements and the framworks all have ways of getting the DOM elements out. You can not magically make a script that works with any library out there, that is why generic plugins normally have library specific extensions to add support.