Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
How would I change the class attribute in my HTML to "night nosmoke" using JavaScript?
<div id="imperium" class="day nosmoke" style="margin-left: -800px; margin-top: -600px;">
I've tried copying the jspath then look at innerHTML but that just brings other stuff up.
I guess this is what you mean. Remove day class and add night class to the element:
document.getElementById('imperium').classList.remove('day');// <---- Remove day
document.getElementById('imperium').classList.add('night'); //<---add class night
console.log(document.getElementById('imperium'))
<div id="imperium" class="day nosmoke" style="margin-left: -800px; margin-top: -600px;">
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 3 years ago.
Improve this question
I want to create a background with Google Maps' fucntionallity.
So here is the idea:
I haven't found any library but I guess it can be solved by css grid.
Can you help me with a piece of advice or just to say how theoretically it can be solved?
You could use jQuery draggable. What you can do is have a container div with the overflow set to hidden and have a draggable image (your background) inside:
$("#draggable img").draggable();
#div1 {
height: 400px;
width: 400px;
background-color: blue;
overflow: hidden;
}
.image {
margin-top: -400px;
margin-left: -400px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="div1">
<span class="move" id="draggable">
<img src="https://placekitten.com/1600/1600" class="image"/>
</span>
</div>
If the snippet doesn't work here is the same code in jsfiddle.
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 6 years ago.
Improve this question
I am trying to display string as
. string1
. string2
. string3
By using Append function of Jquery how to build string with bullet format.
Seeing as html lists are set up using ul and li tags, we can create a html list as follows:
<ul class="myList">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
To append to it using jQuery:
$(".myList").append("<li>New Item</li>");
See the following JSFiddle to see it in action: JSFiddle -
That code adds an item to the list after 3 seconds, so you can see it being appended.
<ul style="list-style-type: normal;" id="list"></ul>
<script>
$('#list').append('<li>string1</li>');
</script>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
A have e3 and e2 divs, and parent div e.
There is too many e divs on the page.
How can I get e3 div value when I click on div e2?
Thanks.
There is no value attribute for div. You could get the innerHTML through javascript.
var divValue = document.getElementById('e3').innerHTML;
Let me first tell you how i understood the question. This is kind of how your html is structured:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="e">
<div id="e2">
i am e2 text
</div>
<div id="e3">
i am e3 text
</div>
</div>
<div id="e">
another e text
</div>
And this is the js code that will give the content of the e3 div when the user click on the e2 div.
$(document).ready(function(){
$("#e2").click(function(){
alert($("#e3").html());
})
});
Hope this helps :)
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 8 years ago.
Improve this question
How would I go about getting which child was clicked when the container is clicked? Whichever child is clicked to store that in a variable?
w
html:
<div class="cont">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
<div class="four"></div>
</div>
By finding the clicked div inside .cont
$(".cont div").click(function(){
var clicked = $(this);
})
FIDDLE
You can use event.target
$('.cont').on('click',function(e){
console.log(e.target.nodeName);
console.log(e.target.className);
});
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Hi guys i have a problem with a selector of jquery.
I have this Html:
<div id="Id_Province_chzn">
<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1">
<span> + this.default_text +
</span>
<div>
<b></b>
</div>
</a>
<div class="chzn-drop" style="left:-9000px;">
<div class="chzn-search">
<input type="text" autocomplete="off" />
</div>
<ul class="chzn-results"> **<-- I need to access here**
</ul>
</div>
I need to append <li> to the <ul> tag, but i don't know how to access.
My idea is to do something like this:
var ul = $(??);
ul.append('<li>some text</li>');
Sorry my english and thanks for your help.
use the class selector
$('ul.chzn-results').append(....)
$('ul.chzn-results') should do it.