我目前有一个内容可编辑的div我用作编辑器,但我想<br>在粘贴上删除html(不包括标签).
目前我有另一个div <div class="hiddendiv common editor"></div>这个收集所有添加到contenteditablediv的文本和数据,以确定contenteditable div的高度.
我变得困惑,不确定我将如何做到这一点.
我的问题是:如何<br>在使用jQuery粘贴时在光标插入处插入文本时删除html格式(不包括标签)?
HTML:
<div contenteditable='true' id="textarea" class="editor plain-box large-box textarea text common text-content-input quicksand color-dark-grey" data-text="Start typing..."></div>
<div class="hiddendiv common editor"></div>
Run Code Online (Sandbox Code Playgroud)
jQuery的
function pasteHtmlAtCaret(html) {
var sel, range;
if (window.getSelection) {
sel = window.getSelection();
if (sel.getRangeAt && sel.rangeCount) {
range = sel.getRangeAt(0);
range.deleteContents();
var el = document.createElement("div");
el.innerHTML = html;
var frag = document.createDocumentFragment(), node, lastNode;
while ((node = el.firstChild)) {
lastNode = frag.appendChild(node);
}
range.insertNode(frag); …Run Code Online (Sandbox Code Playgroud) 我现在正在使用codeigniter.我目前能够通过使用来查看个人资料,/user/profile/profile_id但我希望能够让用户只需导航到个人资料/username以使其更简单.
我怎么会这样做我不知道从哪里开始?
class User extends CI_Controller{
public function index(){
if($this->session->userdata('is_logged_in')){
redirect('user/profile');
}
}
public function profile(){
$profile_id = $this->uri->segment(3);
$ip = $this->session->userdata('ip_address');
$curr_user = $this->session->userdata('id');
$data['profile'] = $this->db->get_where('users', array('id' => $profile_id))->row_array();
$data['followers'] = $this->db->get_where('followers', array('following_id' => $profile_id))->num_rows();
$data['following'] = $this->db->get_where('followers', array('follower_id' => $profile_id))->num_rows();
$data['doesFollow'] = $this->db->get_where('followers', array('follower_id' => $curr_user, 'following_id' => $profile_id))->num_rows();
$data['posts'] = $this->db->get_where('posts', array('user_id' => $profile_id))->result_array();
$data['main_content'] = 'profile';
$this->load->view('template', $data);
$this->get_profile_view($profile_id, $ip, $curr_user);
}
}
Run Code Online (Sandbox Code Playgroud)
routes.php文件
$route['default_controller'] = "signin";
$route['404_override'] = '';
Run Code Online (Sandbox Code Playgroud)