Jump to content

[ JavaScript / HTML ] كيف اربط


Recommended Posts

السلام عليكم

 

شلون اربط الانبوت بالزر بحيث اذا كتب شي بالانبوت وضغط عالزر ينفذ له شي

 

مثال

<html>



<body>
<input type="text" id="input"></input>
<button type="submit" id="button" onclick="d">Count</button>


<p id="demo"></p>



<script>



function d () {

var i = window.input

document.getElementById("demo").innerHTML = txt.length;
}



</script>
</body>

</html>

 

Edited by [KilleR]
Link to comment
<body>
  <form>
    <input type="text" name="text" id="input" placeholder="Enter Text" />
    <button type="submit">Print Now</button>
  </form>

  <p id="text"></p>

  <script>
    let form = document.querySelector('form'),
    input    = document.getElementById('input'),
    text     = document.getElementById('text')

    form.addEventListener('submit', (e) => {
      e.preventDefault() // منع الافتراضي الي هو تحديث الصفحة لارسال البيانات للسيرفر
      text.innerHTML = input.value
    })
  </script>   
</body>

 

Edited by NitroNN
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...