0

フォロー ボタン (twitter など) を作成しようとしていますが、大部分は機能していますが、PHP スクリプトから HTML を生成すると、そうではありません。

これが機能していることを示すフィドルは次のとおりです。http://jsfiddle.net/MCam435/HpAWH/10/

素晴らしい作品:)

ただし、PHPから生成すると:

PHP スクリプト

function getTalent($row) {

     return "<div class='talent_result_wrapper' data-experience='" . $row['divTagExp'] . "' data-salary='" . $row['divTagSal'] . "'>
      <div class='talent_result_header'>
        <span class='talent_result_head'>ID: </span>" . $row['CandidateID'] . "
      </div>
        <ul>
          <li><strong>Resides:  </strong>" . $row['Town'] . "</li>
          <li><strong>Salary Required:  </strong>£" . $row['SalaryMin'] . "</li>
          <li><strong>Experience:  </strong>" . $row['CandidateExperience'] . " Years </li>
          <li><strong>Industy:  </strong>" . $row['PrimarySector'] . "</li>
          <li><strong>Specialism:  </strong>" . $row['PrimarySector'] . "</li>
          <br>
          <div id='follow1'><a href='#' class='follow' id='1'><span class='follow_b'> + Tag </span></a></div>
          <div id='remove1' style='display:none'><a href='' class='remove' id='1'><span class='remove_b'> - UnTag </span></a></div>
      </div>";
    }

メインページ

while($row = mysqli_fetch_array($result2)) {
                echo getTalent($row);
            }   

出力はまったく同じですが、div 間の切り替えが機能しませんか?

4

1 に答える 1

3

1 つのページに同じ ID を持つ複数の要素を含めることはできません。

     <div id='follow1'><a href='#' class='follow' id='1'><span class='follow_b'> + Tag </span></a></div>
     <div id='remove1' style='display:none'><a href='' class='remove' id='1'><span class='remove_b'> - UnTag </span></a></div>

これらの要素にはすべて一意の ID を与える必要があります。ページにこれのインスタンスが 1 つしかない場合は機能しますが、複数追加するとすぐに失敗し始めます。そのため、例では機能しますが、PHP を使用する場合は機能しません。

于 2013-09-19T09:41:42.330 に答える