JavaScript Get HTML with current input values jquery html with current element,html copyright with current year,

An input has a value attribute that determines the initial value of the input. It also has a value property that holds the current value of the input.

It appears that you want to export the HTML markup of the page, where the value attributes of all inputs are set to the value of the value property.

You can do so as follows:

// first, set `value` attribute to value of property for all inputs
$('input').attr('value', function() {
  return $(this).val();
});
// export HTML with correct `value` attributes
$('html').html();

And here is a little demo of that in action.

$('#export').on('click', () => {
  $('input').attr('value', function() {
    return $(this).val();
  });
  console.log($('html').html());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<p>Some paragraph.</p>
<input type="text" value="initial value" />
<h1>Header</h1>
<p>Another paragraph</p>
<button id="export">Export page</button>
Answer:1

for input value inside html use this code may got some help

$("#html input[type=text]").each(function(index,value) {     
    val = $("#"+value.id).val();
    alert(val)   
});
Answer:2

Assuming "html" itself is an id of an element, you can try cloneNode.

var clonedElem = document.getElementById("html").cloneNode(true);

This clonedElem is a DOM object which contains both html as well as values ( and all other attributes). You can now use this DOM for all your purposes.

For Eg. If you wish to insert it into another element, you can do like

document.getElementById('newElement').appendChild(clonedElem)

This will put the entire node with its values

Answer:3

As commented before,

.html() or innerHTML will return the markup. value is a property associated with input elements. Yes you have a tag, but eventually you end you initiating this property. So when you change value dynamically, it updates property and not attribute

You will have to loop over all the inputs and set value attribute.

function updateAttribute() {
  var parent = document.querySelector(".content");
  var inputs = parent.querySelectorAll("input");

  for (var i = 0; i < inputs.length; i++) {
    inputs[i].setAttribute("value", inputs[i].value);
  }
}

Working Demo

Answer:4

If you want to get input values I will do with .attr to change dynamically element value !

$("ButtonToCatchInputValue").click(function(){
        $("input").each(function(){
            $(this).attr("value",this.value);
        });
        console.log($("html").html());  
    });
Answer:5

import Request from 'superagent'; const getApi = () => { let url = '/* URL */'; return Request.get(url).then((res) => { this.setState({ content: res.body });...

import Request from 'superagent'; const getApi = () => { let url = '/* URL */'; return Request.get(url).then((res) => { this.setState({ content: res.body });...

  1. setstate in external function
  2. react setstate from external function

With the help of the following code i am able to embed google search bar within my website <iframe id="if1" width="100%" height="254" style="visibility:visible" src="http://www.google.com/custom?q=...

With the help of the following code i am able to embed google search bar within my website <iframe id="if1" width="100%" height="254" style="visibility:visible" src="http://www.google.com/custom?q=...

I want to add the Shipping and Billing addresses form in the cart.liquid file so it is possible to add these two addresses form in cart page if anybody known then give solution for this.

I want to add the Shipping and Billing addresses form in the cart.liquid file so it is possible to add these two addresses form in cart page if anybody known then give solution for this.

  1. shipping billing addresses
  2. shipping billing address difference
  3. billing/shipping address mismatch
  4. billing shipping address javascript
  5. shipping address billing paypal
  6. billing shipping address form
  7. shipping address billing address
  8. shipping address billing information
  9. shipping vs billing address
  10. shipping and billing address don't match
  11. shipping and billing address in amazon
  12. shipping and billing address lazada
  13. shipping and billing address meaning
  14. shipping and billing address must match
  15. supreme shipping billing address
  16. amazon shipping billing address different
  17. drop shipping billing address
  18. shipping cart billing address
  19. ebay shipping billing address different
  20. shipping and billing address in gst

How do I access the paper-button with id='signin' outside of the Polymer constructor. I need to access it from Template.{template-name}.rendered method. Is there a way to use selector for paper-button?...

How do I access the paper-button with id='signin' outside of the Polymer constructor. I need to access it from Template.{template-name}.rendered method. Is there a way to use selector for paper-button?...

  1. access shadow dom polymer
  2. polymer access shadow dom element
  3. polymer access shadow root