Using jQuery selectors with Javascript functions throwing errors -


trying change using jquery , playing around more native javascript. however, keep getting problems when trying use jquery functions native selectors , javascript functions jquery selectors.

below simple example problem (all run separately):

var text = document.getelementbyid("text"); var text2 = $("#text");  text.style.color = "blue"; //this works     text.css("color", "blue"); //throws text.css not function error  text2.css("color", "blue"); //this works text2.style.color = "blue"; //throws cannot set property 'color' of undefined error 

i thought jquery javascript , use native functions , methods jquery selectors , vice versa. missing?

in code text not jquery object. , not have css function. use javascripts methods in case.

non-jquery objects has native functions only.

upd: jquery object not have style property. call style.color , equal try color of undefined.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -