Javascript for jquery

How do I write the following line that is in javascript in jQuery?

var variablename = new functionname('some variable');

      

This is my js code: var rt = new ResizeableTextbox('myRT');

I need to use this in the following code segment:

 if($(this).text() =='String')
 {
    $("<label id=labelstr"+stringinc+" >"+label+"</label>").appendTo(".menu li");            
    $("<input id=inputstr"+stringinc+" type= 'text' ></input>").appendTo(".menu li");              
    //in place of this I need that javascript code.
 }

      

How can I do it? The Resizeable function is defined in a separate js file. Please help me.

0


a source to share


2 answers


I don't think you ... this is fundamental JavaScript syntax. jQuery adds abstractions and utilities, etc., but does not rewrite major parts of the language.

Here is some sample JavaScript code for jQuery

Plain Ol 'JavaScript

var myForm = document.getElementById('myForm');

      



JQuery

var myForm = $('#myForm');

      

These two lines essentially do the same thing, measure a variable called "myForm" that holds a pointer (is this the correct word?) For the element with the ID myForm

. The advantages of using jQuery in this example are the more concise syntax and the ability to use the selector system you should already know, CSS.

+8


a source


As long as the JavaScript file that defines the function ResizeableTextbox

is included in the section of the <head>

page, the function ResizeableTextbox

can be called anywhere, including inside your if statement ... You probably need to edit your question to describe in more detail what you are trying to do and what is happening instead, because from what you explained, it should work fine.



0


a source







All Articles