My question may be stupid, because I am new to web development and I am so confused now.
First part of my question is that, sometimes when I print stuff using console.log(some element)
, it gives me a giant object with all the listeners but sometimes it just returns a html string merely like this:
<option value="CS 245">CS 245</option>
The way I found some element
like above is using selector as follows:
$( ".course_list option:selected" )[0]
I am sorry about my terminology here because I really want to know the difference between the complex object and the object above (also the name of them). I have tried my best to choose my words, but I fail to make it clearer due to lack of experience. If someone understand what I mean please help me edit this question and provide answers, thanks in advance.
Then the second part of my question is that I want to get that "CS 245" string from the above object.I have tried
$( ".course_list option:selected" )[0].val();
$( ".course_list option:selected" )[0].attr("value");
$( ".course_list option:selected" )[0].text();
but all of them give me this error:
Uncaught TypeError: undefined is not a function
I have included jquery and there is no other crash/file_not_found shown in console. I am using latest bootstrap and formstone selecter, but I am not sure how that affects me here.
Can anybody help?