Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8836221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:26:38+00:00 2026-06-14T09:26:38+00:00

I have the following div: <div contenteditable=true unselectable=off id=foo> inside this div I want

  • 0

I have the following div:

<div contenteditable="true" unselectable="off" id="foo">

inside this div I want to make a specific amount of words look bold everytime a user makes an input. Therefor I have the following changelistener:

$('#foo').live('focus', function() {
   before = $(this).html();
}).live('blur keyup paste', function() { 
   if (before != $(this).html()) { $(this).trigger('change'); }
});

$('#foo').live('change', function() {
   // make certain words bold
   document.execCommand ('bold', false, null); // doesn't work
});

I tried to use the document.execCommand() but it only works when I select the text which I want to make bold. But I don’t want to select the text because the user doesn’t know the words which should be bold.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:26:40+00:00Added an answer on June 14, 2026 at 9:26 am

    You can not use execCommand to bold text without selecting it first.

    I don’t understand what are you doing exactly, but if you know the words you want to make bold, just replace them with <strong>your word</strong> in the editors html, using js.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a contentEditable div with following text for example: <div contentEditable='true'> This document
I have a following structure <div> <ul id='t1'> <li id='l1' contenteditable='true' class='editable'> Lorem ipsum
Currently I am making an editor using contenteditable. I have the following: <div contenteditable=true>
I have following code: <div contentEditable=true> Blah blah <a href=http://google.com>Google</a> Blah blah </div> Fiddle
I have the following div: <div id=foo data-callback=function(){console.log(1)}></div> I want to be able to
I current have a need to have a contenteditable div tag inside an li
I have the following XPath: //div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href When I try out this XPath
I have the following div structure <div id=main_div> <div id=lastChildDiv></div> </div> now I want
I am using Mootools and I have the following div: <div class=total-title>12</div> I want
Possible Duplicate: jQuery refresh if PHP file echo's 'true' I have the following div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.