-1

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.

1
  • What exactly do you want the resizable textbox to do where the comment is? Commented Apr 23, 2010 at 12:57

2 Answers 2

8

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

Plain Ol' JavaScript

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

jQuery

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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. }
@Angeline: Edit the question to reflect what you are actually trying to accomplish and I'm sure someone will be able to help you.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.