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 1 year ago.
Improve this question
i am trying t get the closest iframe element to a parent element so can identify the iframe that i want to stylize with css:
<div class ="accroche">
<iframe></iframe>
<iframe></iframe>
<iframe></iframe>
<iframe></iframe>
</div>
What would be the best technique knowing that the iframes are generated by another tool and there is no way to identify them
Well if I understand your problem it’s the first element of the list so you can do something like that in your css to style it :
.accroche iframe:first-child{ … }
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 5 months ago.
Improve this question
I need to change 2 divs up and down by using javascript dom manipulation, without touching html.
<div class="div1"> this needs to go bottom</div>
<div class="div2"> and this needs to go up</div>
Is it possible to manipulate html structure with js?
You can do like this, swap the elements order in the parent node.
var div1 = document.getElementsByClassName("div1")[0];
var div2 = document.getElementsByClassName("div2")[0];
div2.parentNode.insertBefore(div2, div1);
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
Weave: http://kodeweave.sourceforge.net/editor/#f6d9a54288f17fb68a8b234ec364dc41
I love JQuery, I do, but just for fun I'd like to learn how to write the following in pure/vanilla JS.
$("iframe").contents().find("<style>").html(cssEditor.value))
Something like this should work:
document
.getElementsByTagName('iframe')[0]
.contentDocument
.getElementsByTagName('style')[0]
.innerHTML = cssEditor.value;
Use the contentDocument property of the <iframe> DOM object to get the inner document.
You can then call normal methods on it like querySelector.
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 8 years ago.
Improve this question
How do I access the content of link to by JavaScript and jquery
<a href='http://example.com' id='my id'>content</a>
First of all the id cannot contain spaces.
Then with jQuery to access the content the value in the DOM you need to use the .html() after the selector.
Here is a working example :
http://jsfiddle.net/zuz660uk/
If on the other end you want the value of href then use .attr('href')
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 8 years ago.
Improve this question
I am trying to change CSS elements depending on situations used in javascript.
an example I had tried was:
if ('image'=="clicked")
{blahblahblah}
'image' would be my div id or div tag in CSS.
I know in Jquery I can use $('#image').click, but I don't think it Jquery will be good for my situation.
Consider document.querySelector. It's powerful, accepting any valid CSS selector. You can even start from another element, such as myElement.querySelector, to only get children of that element that match the selector. Very useful!
Just be aware that IE7 and below do not support this function.
Assuming your id as image
document.getElementById('image').onclick = function() {
alert("button was clicked");
};
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 8 years ago.
Improve this question
I want to change the div's style which is located in the parent of a parent. I am able to access them via DOM, but how can I change its CSS style using JQuery?
Selection code:
window.parent.parent.parent.document.getElementsByTagName('code').
I would love to only change a div that doesn't have display:none already set, but I really don't care if we change only one, or all of them.
You can always use the context parameter on $( selector [, context ] )
$("[name=code]",parent.parent.parent.document).css('display','none');
If you want to only change the one that are visible you can use the is function in JQuery in order to filter:
$("[name=code]",parent.parent.parent.document).is(':visible').css('display','none');
JQuery page: https://api.jquery.com/jquery/