jQuery GET
Get Content by text()

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

    $("#btn").click(function(){

        alert($("#test").text());

    });

});

</script>

</head>

<body>

<p id="test">This is testing Content</p>

<button id="btn">Click Here</button>

</body>

</html>

Get Content by html()

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

    $("#btn").click(function(){

        alert($("#test").html());

    });

});

</script>

</head>

<body>

<p id="test"><b>This is testing Content</b></p>

<button id="btn">Click Here</button>

</body>

</html>

Get Content by value()

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

    $("button").click(function(){

        alert($("#username").val());

    });

});

</script>

</head>

 

<body>

<p>

<input id="username" name="username" value="shishirphpdeveloper"/>

<button>Show Value</button>

</body>

</html>

Get Attributes Value

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

    $("button").click(function(){

        alert($("#username").attr("name"));

    });

});

</script>

</head>

 

<body>

<p>

<input id="username" name="username" value="Test value"/>

<button>Show Value</button>

</body>

</html>


Previous
Next