What if I request the URL htt开发者_运维问答p://www.google.com via AJAX, for example and in the on success
function I just wanted to display the I'm feeling lucky button in some div?
For example
$.ajax({
url: 'www.google.com',
success: function(html) {
$('div').html(html);
}
});
this is for displaying the whole page, but I want only to display the button. How do I do that?
$.ajax({
url: 'www.google.com',
success: function(html) {
$('div').html($(html).find('input[name=btnI]'));
}
});
You can replace input[name=btnI]
with your own condition.
You could put a div around the button like:
<div id='button'><button>blah</button</div>
and the Ajax URL would be something like:
url: 'www.google.com #button',
Just add the selector to the end of the URL and it will return only that content.
精彩评论