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 5 years ago.
Improve this question
How can I read this <div class="aigjdd">Mumbai, Maharashtra, India</div> by using JavaScript
Thanks
You can use loop in javascript:
var data = document.getElementsByClassName("aigjdd");
for (var i = 0; i < priceEls.length; i++) {
var FinalData = data[i].innerText;
alert(FinalData);
}
just select your data using javascript selector then use it or show it as you want
var data = document.getElementsByClassName('aigjdd')[0].innerHTML;
alert(data );
<div class="aigjdd">Mumbai, Maharashtra, India</div>
You can use querySelector, which will return only one Element
console.log(document.querySelector("aigjdd").innerText);
Related
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 6 years ago.
Improve this question
I want to parse html string
<!DOCTYPE html><html><head></head><body>....<some tag></some tag>...<script> </script></body></html>
How can I do this?
Code:
<iframe id="FileFrame" src="about:blank"></iframe>
<script>
var doc = document.getElementById('FileFrame').contentWindow.document;
doc.open();
doc.write('<!DOCTYPE html><html><head></head><body>....<some tag></some tag>...<script></script></body></html>');
doc.close();
</script>
Simply using the jQuery function will do that for you.
var myHtml = "<html><body><b>Some Text</b></body></html>";
var myDocument = $(myHtml);
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 am creating with this function some dynamic div. The function is working, but i want to contain one same image in front of each innerHTML name. how is this possible?
thanks in advance
function createdivbusiness(returned_data){
var output = document.getElementById("business");
for (var i=0; i<returned_data.name.length; i++){
var element = document.createElement("div");
element.setAttribute("id",'business'+i);
element.setAttribute("tabIndex","0");
element.setAttribute("class","styled-business");
element.innerHTML=returned_data.name[i];
output.appendChild(element);
}
}
You could do like this
element.innerHTML= "<img src='path_to_image' alt='some text'>" + returned_data.name[i];
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
Tell me how to make a jQuery:
count <div class="one">, divided into two and add between them <div class="two">
/div class="one"/ can be a different number
JsFiddle
You want to add a div after the half of the one divs:
var count = Math.floor($('.one').length / 2);
$('.one').eq(count).after('<div class="two">d</div>');
Demo: https://jsfiddle.net/c8b8tnm3/2/
You can use a class selector to find all the one elements, then use its count(length property) to find its middle and insert the new element
var $ones = $('.one');
$ones.eq(Math.floor(($ones.length-1)/2)).after('<div class="two"></div>')
Demo: Fiddle
Try this, this may help you.
var ones=$('.one');
var indexofOne=$('.one').length/2;
indexofOne=Math.floor(indexofOne);
var insertPosition=$('.one')[indexofOne];
$(insertPosition).after($('<div class="two">'));
JSFiddle
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've got a label for an input. Defined like:
<label for"idofparentelement">innerHTML</label>
Found nothing where the label for hasn't got an id.
How can i remove it with JavaScript without giving an id.
To remove element with specific attribute Use this function:
function removeElem(tag,atr,vl)
{
var els = document.getElementsByTagName(tag);
vl=vl.toLowercase();
for (var i = 0; i<els.length; i++) {
var elem=els[i];
if(elem.getAttribute(atr)){
if ( elem.getAttribute(atr).toString().toLowercase()==vl){
elem.remove();
return;
}
}
}
}
and First of all
Change your html like:
<label for="idofparentelement">innerHTML</label>
Now for your case Use this as: removeElem('label','for','idofparentelement');
Here is the working:
Fiddle
Hope it'll help you cheers :)!!
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 having trouble with adding a onClick event within JavaScript variable. Not sure how the syntax should be written. Thanks for any help.
var jumpTo = 'https://google.com/ onClick="_gaq.push(['_trackEvent', 'link', 'Clicked',]);"'
i think this is what you're trying to achive:
html:
<input type="button" value="Click me" onclick="btn_click()" />
javascript:
function btn_click() {
var url = 'https://google.com';
_gaq.push(['_trackEvent', url, 'Clicked']);
window.location.href = url;
}
hope that helps.
try to escape the single quotes
var jumpTo = 'https://google.com/ onClick="_gaq.push([\'_trackEvent\', \'link\', \'Clicked\']);"'
lg
fastrde