I have PartialView with <p>
Here is code
<p id="findings-date" class="blue-text">Test</p>
I load partialView into div via this js code
$(document).on('click',
'.findingval',
function () {
var findingval = $(this).text();
var idvalue = $(this).siblings('.idvalue').text();
$('#left-window').load('@Url.Action("Findings", "PatientDatabase")');
});
I need to change value of p
to findingval
I tried
$('#findings-date').text(findingval);
but it not works.
After this I tried just to get value like this $('#findings-date').text();
But it's null. Why so?
Seems it try to get data when partialView not appended.
Full code of script
$(document).on('click',
'.findingval',
function () {
var findingval = $(this).text();
var idvalue = $(this).siblings('.idvalue').text();
$('#left-window').load('@Url.Action("Findings", "PatientDatabase")');
var date = $('#findings-date').text();
alert(date);
});
load()
is asynchronous. Use the complete callback so the new html is loaded before you try to access it
$('#left-window').load('@Url.Action("Findings", "PatientDatabase")', function(){
// new html exists now
$('#findings-date').text(findingval );
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.