我从我的数据库中提取文字并插入 P TAG ,其 类 作为我的监听器,但是当我点击文本时,JavaScript没有任何反应。
网站:http://fluentabc.com/edit.php
HTML
<p class="sec_text" id="sec_1" data-reveal-id="myModal">
<?php
$query = mysqli_query($con,"SELECT * FROM site_edit WHERE site_sec='MainTitle'");
while($qt = mysqli_fetch_array($query)){
echo $MainTitle = $qt['site_txt']; // <-- I WANT TO CLICK ON THIS TEXT
}
?>
</p>
JS
$(document.body).on('click', '.sec_text' ,function(){
var txt = $(this).text();
var sec_id = $(this).parent().attr('id');
$("#curEditing").html("Your Editing : " + sec_id);
$("#sec_edit_name").val(sec_id);
tinyMCE.activeEditor.setContent(txt);
});
答案 0 :(得分:-1)
只需更新您的html代码100%正常工作:
您的输出应该是这样的:
<p class="sec_text" id="sec_1" data-reveal-id="myModal">Learn English Today!</p>
更新HTML
<p class="sec_text" id="sec_1" data-reveal-id="myModal">
<?php
$query = mysqli_query($con,"SELECT * FROM site_edit WHERE site_sec='MainTitle'");
while($qt = mysqli_fetch_array($query)){
echo $MainTitle = strip_tags($qt['site_txt']); // <-- I WANT TO CLICK ON THIS TEXT
}
?>
</p>
答案 1 :(得分:-1)
/Applications/MAMP/bin/php/php5.6.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin