Mam jQuery ajax get, który zwróci tekst w html. Z tego muszę wyodrębnić element h3 (z id = "title") wartość: THIS IS TITLE
.jQuery parsować dane odpowiedzi ajax i uzyskać identyfikator elementu - wartość
Czy mogę to osiągnąć dzięki jQuery?
<div class="content">
<h3 id="title">THIS IS TITLE</h3>
.....
</div>
i tutaj jest wezwanie:
$.ajax({
url: url,
type: 'GET',
cache:false,
success: function (data) { // data is the html text returned
alert('The title is: ' + TITLE HERE);
}
});
Może za pomocą znaleźć Zgaduję? –
'$ (data) .find ('# title'). Text()' – undefined
Ponieważ id jest unikalny, możesz użyć $ ("# title"). Text() –