Can you help me convert this jquery to javascript? Thanks.
<script>
$(document).ready(function() {
$("a.false").click(function(e) {
$(this).closest("tr.hide").hide("slow");
var main_id = this.title;
var display = "false";
e.preventDefault();
$.ajax({
url: "/useradminpage",
data: {main_id: main_id, display: display},
success: function(data) {
//display_false();
}
});
});
});
</script>
Yes you can, but your going to have to learn ES5, DOM4 & XHR2.
You need an
toArrayutility to manipulate NodeList and HTMLCollection.Here you need to get all the
class='false'elements and then filter then by whether they are<a>elements.For each element you want to find the parent
<tr>. You do this by looping up the parentNode chain as shown. You also need to handle theparentTr === nullcase more elegantlyAttach a click handler. Change your jQuery hide animation to be done with hard ware accelerated CSS3
Open a XHR2 request. Point it at your url with the GET method. Then attach a readystatechange listener and finally send data down the request.
Disclaimer: Browser support is a pain. You will need the following shims
Further reading:
The interfaces I have used are
You should also read up on ES5.1