Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. How to trigger on change on a HTML5 var tag?

How to trigger on change on a HTML5 var tag?

Scheduled Pinned Locked Moved JavaScript
htmldatabasetutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nicky Tse
    wrote on last edited by
    #1

    <input id="rdo1" type="radio" name="rdoTest" value="Hello" />
    <input id="rdo2" type="radio" name="rdoTest" value="World" />
    Test Value

    $(document).ready(function () {
    $('[name=rdoTest]').change(function () {
    $('#test1').text($('[name=rdoTest]:checked').val());
    });

    $('#test1').change(function () {
        alert($('#test1').text());
    });
    

    });

    My code here but nothing happened

    Richard DeemingR P 2 Replies Last reply
    0
    • N Nicky Tse

      <input id="rdo1" type="radio" name="rdoTest" value="Hello" />
      <input id="rdo2" type="radio" name="rdoTest" value="World" />
      Test Value

      $(document).ready(function () {
      $('[name=rdoTest]').change(function () {
      $('#test1').text($('[name=rdoTest]:checked').val());
      });

      $('#test1').change(function () {
          alert($('#test1').text());
      });
      

      });

      My code here but nothing happened

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      You have already posted this in the Web Development forum: How to trigger on change on a HTML5 var tag? - Web Development Discussion Boards[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • N Nicky Tse

        <input id="rdo1" type="radio" name="rdoTest" value="Hello" />
        <input id="rdo2" type="radio" name="rdoTest" value="World" />
        Test Value

        $(document).ready(function () {
        $('[name=rdoTest]').change(function () {
        $('#test1').text($('[name=rdoTest]:checked').val());
        });

        $('#test1').change(function () {
            alert($('#test1').text());
        });
        

        });

        My code here but nothing happened

        P Offline
        P Offline
        Peter Leow
        wrote on last edited by
        #3

        The second event is triggered by the radio change, you can either place the alert in it or get it to trigger the second event, e.g.

        <script>
        $(document).ready(function () {
        $('[name=rdoTest]').change(function () {
        $('#test1').text($('[name=rdoTest]:checked').val());
        $("#test1").trigger("change");
        //alert($('#test1').text());
        });
        $('#test1').change(function () {
        alert($('#test1').text());
        });
        });
        </script>

        Peter Leow https://www.amazon.com/author/peterleow

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups