I know there are better ways to do this, but I'm currently trying to use Jquery to populate my pop-up email form's subject line to populate with the given class name of the current element. I've gotten it to the point where it will populate properly, but it is dumping in ALL of the names using that class, when i only want it to pull the specific one in which the button is nested:
var carname = $('.car-name').text();
$('input[id="email-subject"]').val(carname);
that is the Jquery of it, how can i get it so it only pulls that specific element's name vs. all of them?
thanks!
****EDIT: Additional HTML info:****
<div class="featuredcar">
<img src="images/cars/1065_00.394180.jpg">
<div class="featuredinfo">
<h5 class="car-name">1968 Mustang</h5>
<p>$10,000</p>
<p><a href="#feat3" id="feat3">More info...</a></p>
<p class="contact-p">
<div class="contact-car">
<i class="fas fa-envelope"></i> Contact Us</div> about this car!</p>
</div>
</div>
<div id="contact-car-form">
<span id="close-form"><a href="javascript:void(0)" onclick="closeForm()">×</a></span>
<h2>Want more Info?</h2>
<small>I'll get back to you as quickly as possible</small>
<form action="#">
<input placeholder="Name" type="text" required />
<input placeholder="Email" type="email" required />
<input id="email-subject" placeholder="Subject" type="text" required />
I need the
input id="email-subject"
to be populated with the text value from
<h5 class="car-name">1968 Mustang</h5>
hopefully, this clears up any confusion. let me know if there is anything else I can provide and thank you for all of your help!