Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

this is the original code of the script

var $mainCat=$('#main_cat').val();

and i replaced it with this

 var $mainCat=$('#<how to pass the slug here>').val();

 echo '<ul>';
  foreach ($termchildren as $child) {
  $term = get_term_by( 'id', $child, $taxonomyName );
  echo '<li><a href="#" id=' .$term->slug. '>' . $term->name . ' </a></li>';
?>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript">
$(function()
{
  $('a#<?php echo $term->slug; ?>').click(function()
  {
    $('#pop-up1').show();
    $('#pop-up').show();
    <?php echo $term->slug; ?>
        var $mainCat=$('#<how to pass the slug here>').val();

now i need to pass the " a href " value i,e. term->slug to the variable $mainCat. How can i do it, kindly help me

share|improve this question
Close voting as this seems like a jQuery question more than anything, so its probably more suited to Stack Overflow. Also, don't include jQuery manually: use wp_enqueue_script() – Stephen Harris Nov 21 '12 at 12:11
+1, it isn't clear what your problem is or what a correct solution would be, the question need to be rewritten to be clearer – Tom J Nowell Nov 21 '12 at 12:22

closed as off topic by Stephen Harris, anu, toscho Nov 21 '12 at 13:13

Questions on WordPress Answers are expected to relate to WordPress within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.