Reputation: 1463
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
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
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
Reputation: 1159
var x = $('outletTitle p').attr('id')
should do
then do what ever you want to do with the variable
Upvotes: 0
Reputation: 2006
<script type="text/javascript">
$(document).ready(function(){
var $temp = $('p').html();
alert($temp);
});
</script>
Upvotes: 0