Output div id data into javascript variable [closed] - javascript

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
Got this div id with html data, how can i output that html data into a javascript variable? example
var url = '(HtmlDivId)'; is this possible?

Are you are trying to read content of the div?
//jQuery
var url = $('#HtmlDivId').html();
//javascript
var url = document.getElementById('HtmlDivId').innerHTML;

Sure
var url = document.getElementById('html-div-id').innerHTML;

Related

Change the H1 tag to H2 using Javascript [closed]

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 2 years ago.
Improve this question
I am looking for a way in Vanilla JavaScript to change the <h1> tag to <h3> tag for this HTML code:
<h1 class="price-heading ult-responsive cust-headformat" data-ultimate-target="#price-table-wrap-3686 .cust-headformat" data-responsive-json-new="{"font-size":"","line-height":""}" style="font-family:'Roboto';font-weight:bold;">Basic</h1>
How can I achieve this?
var el = document.getElementsByTagName('h1')[0];
var dummy = document.createElement('h2');
dummy.innerHTML = el.innerHTML;
el.parentNode.replaceChild(dummy, el);
https://jsfiddle.net/Lzg47mek/

Call function inside href using Jquery [closed]

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 have this link
Test
Now when i click directly on the link .. The alert get popped up in my window.
But, $("#myLink").click();
doesn't call the popup.
EDIT : I need to trigger the function inside href using jQuery
Solved --------- :
var x = $('#myLink').attr("href");
window.location = x;
Figured out..
var x = $('#myLink').attr("href");
window.location = x;
getting the href value and then targeting it .. solved the problem.
Try href="javascript:alert ('test')" or onclick="alert ('test')"

get webpage html element values without opening the page in new window or new tab using JavaScript [closed]

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
Just like the title says I need a way to get the HTML of a webpage with out opening it in a new tab or window. I am making a chrome extension that will take element values from one page and append them to another page.
var htmlObject = gethtml("url");
would like some thing like this
You can use jQuery to get the content of the webpage:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
var htmlObject;
var yourURL = 'url.html';
$.get(yourURL, function(html) {
htmlObject = html;
});

How do I make every TR tag in a table a link with Perl and Javascript [closed]

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
If I have a tag called "post" and has href="something from perl" what should i use for javascript in order to make it clickable and redirects me to the link?
If you implement jQuery you can do something like this:
jQuery(document).ready(function($) {
$(".click").click(function() {
window.document.location = $(this).attr("href");
});
});
edit
assuming your tag looks like this
<tr class = "click" href = "<%= something from Perl %>">

Adding HTML content to jQuery parameter [closed]

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
I have a Javascript function that gets a parameter which is initialized as follows:
In some Javascript class:
var element = new Element('li');
element.addClass('section');
element.addClass('section-' + r);
element.setStyle('width', this.sumWidth);
this.ulBody.appendChild(li2);
this.options.load({parent: element});
I've passed my js function to the class above (I reach the code below when the class above runs):
function load(params){
}
My question is how I can add HTML content to the params.parent?
User .innerHTML
params.parent.innerHTML='<h1>your html</h1>'

Categories

Resources