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)
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 5 months ago.
Improve this question
This is normal text : I need to change an image element's source using ${} with an entry but it doesn't recognize the $ sign as an directory.so it doesn't load any picture because it simply doesn't find a picture with name of "dice-${dicee}.jpg"
here is the code:
document.getElementsByClassName('btn--roll')[0].addEventListener('click',()=>{
const dicee = Math.trunc(Math.random()*6)+1;
diceElement.classList.remove('hidden');
diceElement.src = 'images/dice-${dicee}.jpg';
})
Interporlation only works inside template literals
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
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 5 years ago.
Improve this question
i am trying to change the onclick value of a Button via Javascript. But in the moment I change its value, the function is executed directly.
document.getElementById('Send').disabled = false;
document.getElementById('Send').addEventListener("click", window.location.href = 'http://www.google.com');
Second parameter must be a function! Try:
document.getElementById('Send')
.addEventListener("click",
function(){window.location.href = 'http://www.google.com'});
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 check box in my html
<input type="checkbox" name"cleanse" id="id_cleanse value="cleanse">Cleanse Selected Data?
I also try and access the state of it to be sent back in a GET for the server
cleanse_state = $("#id_cleanse").is(':checked')
then
$.get("/proj/prij/",
{
cleanse_state: cleanse_state,
},
function(data){
spacing()
});
But on the server side whenever I access this, the state is always False - irrelevant of whether or not the check box is checked or not.
How can this be?
That is because you are not closing the " of Id attribute. And also you have omitted equal sign on your name attribute
<input type="checkbox" name="cleanse" id="id_cleanse" value="cleanse"> Cleanse Selected Data?
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();