Using "contentEditable" On Span And Auto-selecting On Click

Dec 1, 2009

I have contentEditable="true" on some span tags on my page. The idea is to allow admin users to edit content inline on the page without having to send them to a giant form page. When only using contentEditable="true" it works fantastically. You can click into the span and type away. Now, the admin users want the text to be selected in the span once they click into it or bring focus to it by tabbing. I'm using the following function onclick and onfocus to get this working:

Code:
function selectText(el)
{
var span = $(el);
// FIREFOX
if (Browser.Engine.gecko) {
var div = document.createRange();
div.setStartBefore(span);
[Code]...

View 2 Replies


ADVERTISEMENT

JQuery :: Selecting Contents Of Span - Result Empty

Jul 25, 2010

I want to select the contents of a span in jquery. This is the html:
<a href="?page=home&action=add&id={$film.film_id}">
<img src="images/shoppingcartButton.png"
id="shoppingButton" alt="shoppingcartButton" title="shoppingcartButton"/>
<span>{$film.film_id}</span></a>

The jquery I have is:
lalala = ($('#shoppingButton span').text());
alert(lalala);
But the result is empty.

View 1 Replies View Related

JQuery :: Stuck On Selecting A Span With Multiple Classes?

Sep 1, 2009

$("span#tak_box").click(function() {
alert("hi");
});

[code]....

View 2 Replies View Related

Auto-selecting All Text In A Field

Nov 28, 2006

I have a simple form that contains an INPUT element that has an initial value.

<form name="Form">
<input name="Number" type="text" value="Hello">
</form>

When the form loads, I want all of the text in the field to be automatically selected. How can I do this?

Doing a:

document.Form.Number.select();

selects the INPUT element itself, not the text inside of it.

View 4 Replies View Related

JS Auto-selecting Option From Select Dropdown.?

Jan 25, 2010

I want to be able to post to a page, and one of the post values, auto selects one of the values in a drop-down box.So say i post a value 'Red' from a field called 'Colors' to a form, I would like 'Red' to be automatically selected in the 'Colors' select dropdown list.I am working with dropdown lists of many values, so need a way to automate this selection.

View 3 Replies View Related

JQuery :: Auto-Selecting Navigation - Add A Class To My Menu For The Page

Sep 12, 2009

I am trying to add a class to my menu for the page it is currently on.

I followed this example: [url]

But I am not able to make it work at all.

Here is my HTML:

To make the nav element highlighted, the list item must have a class of 'hover' like this '<li class="hover">...'

And here is my jQuery:

The script is not applying any CSS to the list elements. I tried different combinations, tried to add a class to the a element by removing parent(), but nothing is triggering.

View 1 Replies View Related

Auto Load File In A PHP Page & If Poss Auto Click Botton On External Page?

Jan 13, 2010

I don't know if this can be done in Javascript, or requires any other language but i was wondering if this would be possible.I would like to embed this Javascript code in to a PHP file and then for it to run automatically upon the PHP file loading:

<td class="smallDesc"> <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script> </td>

[code]....

View 2 Replies View Related

Div Span / Click An Image Like Loading To Appear?

Nov 25, 2009

I have a tree am working it dynamically on server side.

i want on click an image like loading to appear.

View 5 Replies View Related

JQuery :: Linking A Dynamically Generated Span Tag To A Click Event?

Feb 7, 2011

I'm making an ajax call to my server and then, with the information I get back,ynamically creating HTML with jQuery, then appending it to my desired div. This part works excellently. The issue I'm having trouble with is I'm only returning five records, so I'm creating a span at the bottom labeled "see all", but even if I give that span a class,it's clearly not registering in the DOM because when I click it, my jQuery code doesn't even know it's there.My question: How do I get those dynamically generated elements to register in my DOM so they can be called by a jQuery click event?I realize that I can just do an inline javascript call to my function and that works fine(ish). The problem is, however, I want specific information about the particular span that I click, and if I call it inline, it doesn't send $(this) to my function... it recognizes $(this) as $(window), not as $(span that I clicked)

View 2 Replies View Related

Selecting The Content Of A Div In A Button Click.

Nov 29, 2006

I'll have a button in page ... and when i click it .. content of a div

tag has to be get selected (i.e what we normally do with mouse to
selecting some part of a page).. then i can do CTRl+C to copy the
selected div content.. to paste it in MS Word or in any other external
application..

i ve tried the select + copy + paste sequence with the use of
temporary text area element to store the innerHTML of Div tag and
copied to Clipboard. but while pasting the selected content in MS word
it appears like the textual tags not html formatted.. but when u do the

same with mouse clicks and drags u get the formatted pasting in ms
word. why? is it possible to just let to user to select a div while
clicking a button, pressing ctrl+c to copy and paste the content in
another application(ms word etc)?.

View 4 Replies View Related

Selecting Multiple Checkboxes On Single Click

Nov 15, 2010

I know how to do a select/deselect all function. Where I'm having issues is with a select some function. I am querying a database to come up with a list of companies. I then query the database to come up with individual names/email addresses associated with each company. (Individuals can appear under under multiple companies, and I need this to continue.) The checkbox name must remain the same from individual to individual.

What I want to happen: When I click on a name that appears multiple times, I want all related checkboxes to then be checked; also, if I uncheck one, all should then uncheck.
What I've been trying: Each record for John Doe has the same id name (not a must, but I thought this would make it easier. Though I don't think it is necessary, I am including a snippet below:

PHP Code:
<form name=form3>
<tr><td colspan=6>--Company A--</td>
</tr><tr>
<td width='3%'><input type=checkbox name=contact_sel id='contact206' value='jane.doe@company.com'></td>
<td width='30%'>Doe, Jane</td>
<td colspan=4> </td>
</tr><tr>
<td colspan=6>--Company B--</td>
</tr><tr>
<td width='3%'><input type=checkbox name=contact_sel id='contact118' value='john.doe@company.com'></td>
<td width='30%'>Doe, John</td>
<td width='3%'><input type=checkbox name=contact_sel id='contact33' value='mike.jones@company.com'></td>
<td width='30%'>Jones, Mike</td>
<td colspan=2> </td>
</tr><tr>
<td colspan=6>--Company C--</td>
</tr><tr>
<td width='3%'><input type=checkbox name=contact_sel id='contact118' value='john.doe@company.com'></td>
<td width='30%'>Doe, John</td>
<td width='3%'><input type=checkbox name=contact_sel id='contact206' value='jane.doe@company.com'></td>
<td width='30%'>Doe, Jane</td>
<td colspan=2> </td>
</tr></form>

Again, if I select/deselect someone from any Company, I want all of their related check boxes to follow suit. If there is a better use of id records, I'm all for it.

View 11 Replies View Related

JQuery :: Finding A Span Nested Inside Another Span?

Sep 13, 2011

If you have span within another span, jQuery selector seems to be unable to find it.example:

<span
>
<span

[code]....

View 2 Replies View Related

JQuery : Selecting A Parent When A Click Event Is Fired On A Child

Apr 27, 2009

In jQuery, how to select a parent element to a child if I attached a click event on the parent but also want a click event on a child within.

Let's say I have a the following code :

HTML Code:

There may be several of those classes in the page. I then use jQuery to replace the inner HTML to the clickclass div when clicked on with some other code and a input button (with an ID of, let's say 'save_button').

This works fine for that part:

HTML Code:

I then want to have the button clickable so that I can replace again the HTML in the div (like a save button). But if I try a separate event listener on the input button, it also fires the parent event. Even if I return false on the child event or use event.stopImmediatePropagation() in the .click child function.

I've managed to almost get it with the following code :

HTML Code:

If the event is triggerd form 'clickclass', then replace with HTML + input button

The problem is that whenever I try using .parent() with jQuery, it always tells me that parent() is not a function. I've tried various other ways of getting the parent object (the clickclass div) but can't get it to work.

View 4 Replies View Related

ContentEditable Problem

Jul 23, 2005

Is it possible to make a SELECT box editable, where a user can type their own entry to be acted upon on top of being able to select an option of course?

View 2 Replies View Related

Auto Click On Pageload?

Sep 13, 2011

what i wanna do is that when smone loads my website, the script initiate the left mouse click automatically. that is on page load mouse click is stimulated.

View 1 Replies View Related

Auto-click The Last Image

Sep 12, 2010

i am new in js and i have a problem on auto click a link..after the slide show of the images i want to auto click the last image, is it possible? this code below that i have search it redirect the link without showing the image slide show..

<script type="text/javascript">
function init(){
var linkPage = document.getElementById('dynLink').href;
window.location.href = linkPage;
}
[Code]....

View 2 Replies View Related

JQuery :: Select Span With Span Parent?

Aug 31, 2009

How would I select all spans which have a span as a parent?

View 2 Replies View Related

ContentEditable DIV & Document.body

Dec 7, 2006

Does a contentEditable DIV have the notion of an internal document? I'm trying to convert code that uses an IFrame.contentWindow.document to use the "document" inside a contentEditable DIV but they don't seem to be similar beasts. Eventually I want to add stylesheets to the contentEditable DIV as well as event handling. I'm porting an IFrame editor to a contentEditable DIV based editor.

View 1 Replies View Related

Set Caret Position In Contenteditable Div

Sep 21, 2010

I have a contenteditable div, it has some paragraphs in it.Assuming a situation, when I click the button "set caret position", the main div will focus, the caret will start at position number 8 of second paragraph, which means the caret will appear after the word "draw".How would you do it?

View 8 Replies View Related

JQuery :: Auto-click From Menu?

May 23, 2010

I have a problem with auto click function jQuery.I use jQuery menu EXAMPLE- (firstmenu) - its good,but I need use auto click toHeader-1 (div block<div id="CLICK" class="menu_body">)and to open a menu with Link-1,Link-2,Link-3

[Code]...

View 2 Replies View Related

Auto Sign In Without Having To Click On Link?

Jun 29, 2010

I really don't know what I am doing, but I need to know how to alter this script to load this website without having to click "Weathersentry online". I would like to double click on the icon the code is attached to and it sign in automatically.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

[code].....

View 3 Replies View Related

Auto Change Class On Click?

Jul 11, 2010

I'm in the process of working on a page that uses layers and iFrames in conjunction with javascript and <div> layers. The problem I'm hoping to solve with your help is that I implemented onclick="this.className='stylesheetstyle'" in the <a href> tag and so therefore when users click the links, the text becomes bold. However since I'm using multiple frames on a page, this makes it look odd when the user back tracks and clicks a different link in the frame. Is it possible using JavaScript to have a users input on click of link unbold the previously clicked link?In short:

Click link -> link goes bold
move forward....
click another link (different frame) -> go forward

[code].....

View 7 Replies View Related

Simulate A Manual Click - Not An Auto One

Sep 14, 2010

After all, there is some difference in the way we 'click' using our mouse at some place in the document, and what can be achieved by the dispatchEvent "click" in Firefox. We have a page, which has two iFrames on whole. Left frame having a table of clickable email subjects, and right frame showing the entire body of the selected email. The problem is, the clickable area on the subject is too small, making it a pain to click each email to see its body. So I implemented a way of navigating through them using keyboard in the parent page(using key handlers in Javascript). The problem is, when we load the page for first, the navigation works fine, since the focus is on the parent page. But as soon as someone clicks on any area on the two iFrames, the key handlers don't work because they are in the parent page, not in that frame.

I noticed that when I click on any area outside the two frames, it works again. Idea : "Why not do a setTimeOut or setInterval sort of thing, which just sits and keeps on clicking on a place outside the frames"? Good idea, but doesn't work. Why? Is installing the same kind of key handlers in both the frames the only other way? Even setting focus on an element on the parent page doesn't work.

View 5 Replies View Related

JQuery :: Getting Caret Position In A Contenteditable Div?

Nov 16, 2010

I'm using a div with contenteditable=true, and I need to know where the caret is for operations like splitting the html contents of that div where the caret is. Ultimately, if a piece of text is selected, I'll want to split that html content on the selection start / end.jCaret only seems to work for textareas.Is this possible in a div?

View 1 Replies View Related

JQuery :: Replace .click With An Auto Function?

Aug 8, 2011

I have some jQuery which I used on a site a couple of years ago. It basically loads some content into a DIV, which can be rotated using a .click function.I'd like to use the same code again, and I have got it working, but instead of having to click a link with a specific ID, I'd like it to automatically run every 4 seconds.

Here is my code:

var $j = jQuery.noConflict();
$j(function(){
var offset = 5;

[code]....

and here is my HTML to trigger the function:

<div id="postContainer">... loading ...</div>
<a href="#" id="another">show another</a></span>

replace that .click function to run automatically every 4 seconds.

View 4 Replies View Related

Auto View Content When Click On The Link?

Oct 12, 2011

Code:http://www.donhkoland.com/about/What code used here, I like the effect. Is there any tutorial for this of effect.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved