I am creating a list of all of my saved AI programs relevant to their name which is done like so and works fine:
@foreach ($ais as $ai)
<a href='#' class='saved-ai'>{{ $ai }}</a> <br />
@endforeach
I then have a jQuery script which is designed to append the value of the name to an input box.
<script>
jQuery(document).ready(function(){
$('.saved-ai').click(function() {
$('#ainame').val(this.html());
});
});
</script>
I tried to debug this
to see what it held and why its behaviour was strange but I get this in my console:
<a href="#" class="saved-ai" name="Languages">Languages</a>
The error I receive is:
Uncaught TypeError: this.html is not a function
at HTMLAnchorElement.<anonymous> (home:107)
at HTMLAnchorElement.dispatch (app.js:1)
at HTMLAnchorElement.g.handle (app.js:1)
After researching, app.js in laravel already includes jQuery. However, It seems that this.html()
does not exist. How can I get the value of the clicked element?
The expected output here would be Language
gets placed inside the input box as the value.