jquery - Append does not work when I try to code in Javascript OOP style -


i learning concepts of programming in javascript oop style , need little help:

first, simple html form:

<form>      <select id="jobrole"></select> </form> 

next, write "question" class:

var question = function() {   this.masterq = function (id1) {     this.id1 = jquery(id1);     this.id1.append('<option value="">test</option>');   }; } 

now instantiate question class, making new object

var q = new question(); 

and call masterq method:

q.masterq('#jobrole'); 

but, have no idea why test isn't appended onto select.

any ideas?

thank you!

i try , code works -> http://jsfiddle.net/hxhh2/1/

are sure included jquery in page

<script src="pathtojquery.js"></script> 

or maybe execute code before dropdown on page. wrap logic into

$(document).ready(function() {    // code here }); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -