Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Yesterday I have put the question which was answered correctly but now I want to convert that same code into javascript. I have made some changes but its not work
working code- http://jsfiddle.net/SXzyR/8/
mycode- http://jsfiddle.net/SXzyR/11/
You want to use this.id instead of document.getElementById(this) to get the id string where this is a DOM element.
Please read some tutorials about jQuery. This is a good start, also have a look here.
jQuery isn't another language, it's a library for JavaScript. Considering the following line from your "translated" code:
txtval(document.getElementById(this)
Instead of writing document.getElementById you can simply use jQuery to write
txtval($(this))
as in the first example (working code).
Also you are mixing jQuery with "native" JavaScript/DOM functions in your code. Don't reinvent the wheel, use jQuery to accomplish your task.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am having a hard time finding a good yet simple article on the 'behind the scenes' of jQuery. I know this is not simple though.
But does jQuery actually uses cycles and states like React does ? If not, what is it, in simple words ?
What is happening when jQuery does that ?
$('.netreviews_stats_stars_big').css('opacity', '0.2');
The DOM manipulation parts of jQuery do direct DOM manipulation. It doesn't take a data-driven approach like React so the idea of state in the React sense is meaningless.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I just found This and it has some comparation with JQuery and others...
Its really faster than the others.
What you guys think about this. Is it ok to use only this? Is there anything that you will HAVE/NEED to use JQuery ?
Also, when it comes to performance. Is there a big difference between:
var test = document.getElementById('test-table');
test.attr('id','123');
var test = document.getElementById('test-table');
test.dataset.id = '123';
It doesn't matter since you can always wrap any DOM element around a jQuery object if you must.
var test = document.getElementById('test-table');
// Do some vanilla stuff
var jTest = $(test);
// Do some jQuery
The jQuery library builds upon the DOM API that is available to JavaScript. The only reason you'd need jQuery is to do a complex task that requires more effort in vanilla. In terms of performance, the difference is negligible. jQuery adds checks to be cross-browser compatible. If you code to modern standards, these checks are not necessary.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
As I am learning vanilla JavaScript right now, I don't always know what to ask when searching through JS documentation (mostly on Mozilla MDN). So, I use what I know in jQuery until I get there.
So, what performance or other drawbacks should I be aware of when using jQ to substitute for my lack of full JS understanding while I learn?
These days, clients run fast enough that you don't really need to worry about any performance differences between vanilla JavaScript and jQuery. Thus, it could be said that this is a sort of "premature optimization", so I give you the same answer I always give: Use what you know/what's easier to maintain until you can demonstrate a critical performance bottleneck via a profiler; only then should you figure out how to improve the performance, possibly including switching to vanilla JS.
You should learn to understand how to retrieve elements from the DOM and how javascript relates to HTML. Basically you are altering html-elements and attributes.
http://en.wikipedia.org/wiki/Document_Object_Model
http://www.w3schools.com/js/js_htmldom.asp
https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm using Notepad++ in writing Javascript files. But the syntax highlighting is not that good there.
For example methods and properties of known objects, like arrays, numbers or even AJAX object are not highlighted at all.
Can this be improved by adding a plugin or something ? if so can you specify a plugin for me ?
Thanks
In Notepad++ you can go to the plugins tab and then to plugin manager and it will show you all available and installed plugins. Just scroll down the list until you find one that suits your needs and install it. If you don't see it on the list I don't think you will find it anywhere else.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have already checked stackoverflow. Their Jquery/Javascript code is cryptic. The variables are all one letter in length. So can you guys give a good website that uses JQuery well and follows good/best practices?
I have already read many books on the subject. I would like to jquery implemented on a large scale.
At the jQuery's homepage jQuery.com you can find several tutorials.
Further on there are books written about jQuery. The one I can recommend is the jQuery in Action. It's a pleasant read.
Here's a showcase of sites which use jQuery:
http://usejquery.com
Here are more topics about the subject:
Where can I find a tutorial to get started learning jQuery?
Where can I learn jQuery? Is it worth it?
I'd recommend the site LearningJQuery.
They've got advanced, intermediate and beginner examples.
I'd suggest that any site who is using the minified jQuery library is doing themselves and their visitors a favour!
How about JQuery itself?