Having trouble grabbing the UL assigned data-value of a particular list item? Let me provide you with the code. I want to fetch the top UL data value along with the LI value. Although I have set up jQuery to grab the LI value, I am struggling to retrieve the UL value simultaneously. Due to my lack of knowledge about jQuery syntax, I find it difficult to do it correctly...
Thank you in advance.
<form class="searchwrapper" id='searchformmain' action="linkdsearchpagination.php" method="POST" enctype="multipart/form-data">
<input type="text" id="searchfor" name="searchfor" placeholder="What Are you Looking for?" class="textsearchmain">
<button name="submitted" type="submitmain" action="submit" target='linkdsearchpagination.php' class="searchbuttonmain">Search</button>
</form>
<div id="ggg" class="col">
<h4 class="ban">Temp jobs</h4>
<div class="cats">
<ul id="tempjobs" data-value='temp jobs' class="left">
<li><strong>Creative</strong></li>
<li><a href="" data-value="tv film video">tv / film / video</a></li>
<li><a href="" data-value="crew">crew</a></li>
<li><a href="" data-value="talent">talent</a></li>
<li><a href="" data-value="event">event</a></li>
<li><a href="" data-value="labour">labour</a></li>
<br>
<li><strong>Computer</strong></li>
<li><a href="" data-value="internet engineers">internet engineers</a></li>
<li><a href="" data-value="web info design">web/info design</a></li>
<li><a href="" data-value="writing editing">writing / editing</a></li>
<li><a href="" data-value="admin office">admin / office</a></li>
<li><a href="" data-value="art media design">art / media / design</a></li>
<br>
<li><a href="" data-value="security"><strong>Security</strong></li>
<li><a href="" data-value="business">business</a></li>
<li><a href="" data-value="public">public</a><li>
<li><a href="" data-value="domestic">domestic</a></li>
<li><a href="" data-value="personal">personal</a></li>
<li><a href="" data-value="transport">transport</a></li>
<br>
<li><strong>Skilled trade / craft</strong></li>
<li><a href="" data-value="education">education</a></li>
<li><a href="" data-value="architech egineering">arch / engineering</a></li>
<li><a href="" data-value="legal paralaegal">legal / paralegal</a></li>
<li><a href="" data-value="business management">business / mgmt</a></li>
<li><a href="" data-value="accounting finance">accounting+finance</a></li>
<li><a href="" data-value="customer service">customer services</a></li>
</ul>
</div>
</div>
</div> <!----central column-------->
</div><!------WRAP-------->
</body>
</html>
<!---get list value and post to form--->
<script>
$("#jobs a,#tempjobs a,#community a,#dating a,#services a,#housing a,#forsale a").on("click", function(e) {
e.preventDefault();
$("#searchfor").val($(this).data('value'));
var data2 = $(this ul).data('value');
$("#catagorymain").val($(this).data2('value')); // IV GOT ISSUE WITH THIS
//$("#searchformmain").submit();
});
</script>