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

  • SEARCH
  • Home
  • 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 9056063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:06:14+00:00 2026-06-16T14:06:14+00:00

I create a small application to add text from textarea to div block..I want

  • 0

I create a small application to add text from textarea to div block..I want when user click on yellow div text not get append and the properties (font family, font size) of the selected text also highlight in the selectbox

$(document).ready( function() {
    $('#page1').click(function(e){
    var $el = $("<li class='text'>"+$('#ta').val()+"</li>"),
        $this = $(this), offset = $this.offset();
    $el.css({
        position: 'absolute',
        left: e.pageX - offset.left,
        top: e.pageY - offset.top
    });
    $this.append($el);
    ($el).draggable();
    $("#page1 li").click(function(){
    $("#page1 li").removeClass('active');
    $(this).addClass("active");

    });
});
        $("#fs").change(function() {
            $('li.active').css("font-family", $(this).val());
        });
        $("#size").change(function() {
            $('li.active').css("font-size", $(this).val() + "px");
        });

      });  

Jsfiddle link: http://jsfiddle.net/sharma_pooja/P2Kyk/31/

  • 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-16T14:06:15+00:00Added an answer on June 16, 2026 at 2:06 pm
    $('#block').click(function(e){
    
        var $this = $(this);
        var $textBlock = $this.children('p');
        var _offset = $this.offset();
    
        $textBlock.css({
            position: 'relative',
            left: e.pageX - _offset.left,
            top: e.pageY - _offset.top
        });
    
    });
    

    And add CSS overflow: hidden; to the #block class. It will hide rest of text which will be overflowing the block when positioned near the block border.


    UPDATE

    For draggable option you should use jQuery UI and can do smth. like this

    $('#block p')
        .draggable() // for moving the `<p>` around with your mouse
        .disableTextSelect(); // to disable text selection inside container
    

    Here is fiddle for both cases: when clicking parent container and dragging the text block itself.

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

Sidebar

Related Questions

I want to create a small java application to copy some wiki content from
I am attempting to create a small application to collect data received from an
I am trying create a small web application that allows a user to login
I create small application which is media player. I have method where I have
I need to create a patching routine for my application, it's really small but
I'm using Visual Studio 2010 to create a small WPF application. I've created a
I have create a field of small panels on a form and I want
I'm attempting to create a small application in which I can make a poul
I'm trying to create a small application to setup fresh windows 7 systems. This
I need to create a small GUI application to manually invoke some driver commands.

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.