[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Compacting JQuery code

Posted on 2009-02-19
2
Medium Priority
?
246 Views
Last Modified: 2012-05-06
I don't know if this is possible, but I wonder if the following code can be put in one line (using sequencing) or one nested command. It works like this, but I'm just curious and want to understand JQuery better.
var title= $("#textfield").val();
$("#item td.first").html(title);

Open in new window

0
Comment
Question by:R7AF
2 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 1000 total points
ID: 23683350
Not sure why you would want to compact it, but this is the only thing I could think of:

$("#item td.first").html($("#textfield").val());

You might however want to reduce the selector to:
$("#item td.first").html(document.getElementById('textfield').value);

-r-
0
 
LVL 13

Author Closing Comment

by:R7AF
ID: 31548788
Thank you! I tried something similar, but didn't get it to work. I'm just starting with JQuery, so the "why" is more about understanding the different ways you can do things.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question