我无法将jquery代码转换为javascript代码

时间:2016-07-05 09:23:48

标签: javascript jquery

我无法将jquery代码转换为javascript代码。我需要在javascript中迭代。请指教我,如何解决这个问题。并且还添加了html代码。你可以检查一次。提前谢谢你。

我在上面的代码中有点小。我在本地试过上面的代码。我想要显示一个值。它工作正常。我希望再显示一个值,在这种情况下实际上它会显示两个值但它显示三个值。请建议我如何解决这个问题。谢谢。例如: - 2 [首先输入值] =>它显示2: - 7 [再输入一个vallue] =>实际上是显示2,7但显示值为2,3,7

这是html代码: -

<?php
$form_fields = array(           
        'acad_year' => array('label' => '', 'label_html' => '', 'after_html' => '', 'required' => FALSE,  'class' => '', 'id' =>'year_select', 'view' => 'input/pulldown','value' => ssp_get_regform_value($user, $type, $formreturn, 'acad_year')),

        'acad_campus' => array('label' => '', 'label_html' => '', 'after_html' => '', 'required' => FALSE,  'class' => '', 'id' =>'campus_select', 'view' => 'input/pulldown','value' => ''),

        'acad_course' => array('label' => '', 'label_html' => '', 'after_html' => '', 'required' => FALSE,  'class' => '', 'id' =>'course_select', 'view' => 'input/pulldown','value' => ''),

        'acad_specialization' => array('label' => '', 'label_html' => '', 'after_html' => '', 'required' => FALSE,  'class' => '', 'id' =>'specialization_select', 'view' => 'input/pulldown','value' => ''),

        'submit' => array('label' => '', 'label_html' => '', 'after_html' => '', 'required' => FALSE,  'class' => '', 'id' =>'profile_edit_submit_stg_1', 'view' => 'input/submit','value' => 'Add a course'), 

    );
    echo "<br>Please select one of the courses below<span class='cnfrm_warning'>*</span><br>";
    //var_export($form_fields);
    ssp_render_regform_array($form_fields);
    ?>
    <div id="acad_debug_pane"></div>
    <div id="acad_result_pane"></div>
    <div id="result_form_div">
    <p><b>Currently selected courses</b></p>

    <form  method="post" id="result_holder_ssp" onSubmit="return acad_result_checkform();" name="acad_final_submit">    
    <input type ="hidden" id="last_course_count" value = "">
    <input type ="submit" name="acad_conditional_submit_" class="regform-submit" id="acad_conditional_submit_id" value="Submit Changes">    
  </div>

var course_map =  new Array(0);
 $("form#result_holder_ssp :input").each(function(){
    var input = $(this);      
      if(input.hasClass('ssp_selected_course') || input.hasClass('ssp_selected_course_sugg')){

          console.log(input.attr("name"));
          course_map.push(input.val());

        }

    });

1 个答案:

答案 0 :(得分:1)

你可以尝试这样的事情:

- 编辑 -

document.getElementById("myDivID").children[0]

我输入的属性为“className”,我最初输入“classname”并且区分大小写,这也是className comparisson中空格的问题。