Reputation: 2379
How do I write the following line which 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 do I do that? The function Resizeable is defined in a separate js file. Please help me out.
Upvotes: 0
Views: 203
Reputation: 11070
As long as the JavaScript file which defines the ResizeableTextbox
function is included in the <head>
section of the page, the ResizeableTextbox
function can be called anywhere including within your if statement... You probably need to edit your question to describe in more detail what you're trying to do and what's happening instead, because from what you've explained it should work fine.
Upvotes: 0
Reputation: 490153
I don't think you would... that is fundamental JavaScript syntax. jQuery adds abstraction and utilities etc, but doesn't rewrite the core parts of the language.
Here is an example of JavaScript code to jQuery
var myForm = document.getElementById('myForm');
var myForm = $('#myForm');
These 2 lines essentially do the same thing, dimension a variable titled 'myForm' which contains a pointer (is that the right word?) to the element with an id of myForm
. Benefits of using jQuery in this example are more concise syntax, and the ability to use a selector system you should already know, CSS.
Upvotes: 8