imrulhasan273
1 month ago

How can I get the value of `<a>` tag from blade into `js` file using JQuery?

Posted 1 month ago by imrulhasan273
<div class="p-rating">
<a value ="1" type="button" class="btn RatingAjax1"><i class="fa fa-star-o"></i></a>
<a value="2" type="button" class="btn RatingAjax2"><i class="fa fa-star-o"></i></a>
<a value="3" type="button" class="btn RatingAjax3"><i class="fa fa-star-o"></i></a>
<a value="4" type="button" class="btn RatingAjax4"> <i class="fa fa-star-o"></i></a>
<a value="5" type="button" class="btn RatingAjax5"><i class="fa fa-star-o fa-fade"></i></a></div>

Here is my process i have given different class name for every button. For one start RatingAjax1 upto 5 star

$(document).ready(function() {
    var i;
    for (i = 1; i <= 5; i++) {
        $(".RatingAjax" + i).click(function() {
            alert("clicked");
            alert(i); 
            
        });
    }
});

In this js file I want to get the value of <a> tag depending on click event.

How When I click on first button then it value ofi should be 1. If i clicked on 5th button value of i should be 5.

How to solve this problem?

Please sign in or create an account to participate in this conversation.