Learn free online HTML5, javascript, and jquery Tutorials by Examples

Monday 14 July 2014

how we can Get Last segment of URL in jquery

-------------------------------------------------
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function(e) {
    var cur_url = window.location.href;
    var lastSegment = cur_url.split('/').pop();
    $('#btn').click(function(e) {
       alert(lastSegment);
    });
});

</script>

-------------------------------------------------

No comments:

Post a Comment