Atul Dhanuka
Atul Dhanuka

Reputation: 1463

how I can get the value of url in <p> tag in html

I want the value of the id which is in url in html paragraph tag. How I do this

jquery

 function get_Table_List(id) {
       $.ajax({
        type: "GET",
        url: "one.html?outlet="+id,
               });

html

<div class="outletTitle" style="text-align:center;">Selected outlet:<p id="preview"></p> 
</div>  

Upvotes: 2

Views: 1429

Answers (4)

Paul Chen
Paul Chen

Reputation: 1881

I don't understand your question clearly.

Did you mean when someone requests one.html?outlet=123, you want that page one.html shows the outlet id in your <p id="preview"></p> tag?

If this is the case, I think you have to parse document.location.href.

Upvotes: 0

Praveen
Praveen

Reputation: 56509

Based on my understanding, using .text() you change the text value.

function get_Table_List(id) {
   $.ajax({
        type: "GET",
        url: "one.html?outlet="+id,
       });
   $('#preview').text(id); // where changes takes place
}

Result:

 Selected outlet:<p id="preview">id</p> 

Or if you want to change the id of the P tag then .prop() is in.

$('#preview').prop('id', id);

Result:

Selected outlet:<p id=id></p> 

Upvotes: 1

soum
soum

Reputation: 1159

var x = $('outletTitle p').attr('id') should do

then do what ever you want to do with the variable

Upvotes: 0

Ganesh Rengarajan
Ganesh Rengarajan

Reputation: 2006

<script type="text/javascript">

$(document).ready(function(){
var $temp = $('p').html();
alert($temp);

});
</script>

Demo

Upvotes: 0

Related Questions