Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have a link:
Manage Lists
I want to "click" this link using jquery or javascript. I've tried:
$("#panel2-2").click(function(){});
$("#panel2-2").trigger('click');
It doesn't work! How can I do a click like this using javascript?
You need to use the jQuery attribute equals selector.
Description: Selects elements that have the specified attribute with a value exactly equal to a certain value.
For your case, you would use something like this:
$( "a[href='#panel2-2']" ).click();
You need
$('[href="#panel2-2"]').trigger('click');
or
$('[href="#panel2-2"]').click();
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 days ago.
Improve this question
When the page loads, I would like to take the actual URL of the page, save it into a variable and then search with jQuery, an element with the same URL of the actual page. If jQuery finds that with the same href, then add a class to that element.
This is what I've actually:
$(function() {
var url = $(location).attr('href');
console.log (url);
$('a[href="${url}"]').addClass( "a-selected" );
});
I'm taking the actual URL correctly. And if I change a[href="${url}] to -> a[href="my-url.com/stacksoverflow"] , the class applies! But when I change to use the $url variable then the class is not appling
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have a div which outerwidth () returns the selector itself in an array
For $('.slidePopup').outerWidth() its returning like this
<div class="slidePopup">
......
<div class="sildeInside"> </div>
</div>
Has someone else faced the same issue?
It seems this is an existing bug and fixed in older version.
https://bugs.jquery.com/ticket/12491
Please check whether you are using latest version of jQuery. If not consider upgrading to latest version of jQuery or pass "false" as argument as mentioned in the link
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
i've building a nodejs app and using jquery in it. I try to get the text from a anchor from an nested list:
<ul class="someClass">
<li>
Anchor Content
</li>
</ul>
My JQuery Code to get the content is:
$('#someClass').find('a').text();
Unfortunately it isn't working. Any ideas?
Use this
$('.someClass').find('a').text();
Use the class selector. Until now, you're just using the ID selector. In jQuery . is the class selector. In HTML you're using the class not the ID. So that code won't work.
For more on jQuery selectors: http://api.jquery.com/category/selectors/
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I'm trying to change the body content when I resize the windows, but after 2 hours searching and trying, I get nothing.
This is my last jQuery code:
$(window).resize(function(){
if($(window).width<=320){
changeHTML();
}
});
var changeHTML=function(){
alert("wow");
//$('body').load('../index2.html');
}
The "index2.html" is something like this:
<div>
A lot of stuff
</div>
$(window).width is incorrect, as width() is a method. Use $(window).width() instead.
See working jsFiddle demo
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I am writing a code for quiz,whenever one option is selected by the user from out of four option,i want to alert. I have something similar to my code here:-
<label class="alert optiona">
</lablel>
I am having value
data.correct="optiona";
I need to send pass the value in javascript.When i am passing following syntax , it doesnt send the value of data.correct.
$(".alert "+data.correct).attr("class", "alert alert-"+ data.mode);
You're missing the dot in the selector and you have a space which means that the second class applies to a descendant of the .alert element.
Change
$(".alert "+data.correct)
to
$(".alert."+data.correct)