¡@

Home 

2014/10/16 ¤W¤È 12:08:04

jquery Programming Glossary: selection

jQuery selector regular expressions

http://stackoverflow.com/questions/190253/jquery-selector-regular-expressions

a wonderful filter that allows regex to be used for selection. Say you have the following div div class asdf Padolsey's regex..

How to disable text selection using jQuery?

http://stackoverflow.com/questions/2700000/how-to-disable-text-selection-using-jquery

to disable text selection using jQuery Does jQuery or jQuery UI have any functionality.. jQuery or jQuery UI have any functionality to disable text selection for given document elements javascript jquery jquery ui share..

Get Cursor Position within a Text Input field

http://stackoverflow.com/questions/2897155/get-cursor-position-within-a-text-input-field

oField Initialize var iCaretPos 0 IE Support if document.selection Set focus on the element oField.focus To get cursor position.. the element oField.focus To get cursor position get empty selection range var oSel document.selection.createRange Move selection.. position get empty selection range var oSel document.selection.createRange Move selection start to 0 position oSel.moveStart..

$(this) selector and children?

http://stackoverflow.com/questions/306583/this-selector-and-children

parameter which can be used to override the context of the selection. jQuery img this Which is the same as jQuery this .find img..

Change CSS of selected text using Javascript

http://stackoverflow.com/questions/3223682/change-css-of-selected-text-using-javascript

SelText document.getSelection else if document.selection SelText document.selection.createRange .text return SelText.. else if document.selection SelText document.selection.createRange .text return SelText However when I created a similar.. SelText document.getSelection else if document.selection SelText document.selection.createRange .text SelText .css 'background..

jqGrid paging question

http://stackoverflow.com/questions/3807623/jqgrid-paging-question

reloadGrid current true allows to preserver current selection. You can of cause combine both options. share improve this..

jqgrid incorrect select drop down option values in edit box

http://stackoverflow.com/questions/4469650/jqgrid-incorrect-select-drop-down-option-values-in-edit-box

function e To be able to save the results of the current selection the value of the column property must contain at least the..

Can the jQuery UI Datepicker be made to disable Saturdays and Sundays (and holidays)?

http://stackoverflow.com/questions/501943/can-the-jquery-ui-datepicker-be-made-to-disable-saturdays-and-sundays-and-holid

in function exists called noWeekends that prevents the selection of weekend days. .selector .datepicker beforeShowDay .datepicker.noWeekends..

Browser Memory Usage Comparison: inline onClick vs. using JQuery .bind()

http://stackoverflow.com/questions/5303471/browser-memory-usage-comparison-inline-onclick-vs-using-jquery-bind

user will click on one from your custom buttons the row selection can stay unchanged. With the onCellSelect the row will be first.. rowid rowid nButton name buttonNames iCol prevent row selection if one click on the button return iCol firstButtonColumnIndex..

Insert html at caret in a contenteditable div

http://stackoverflow.com/questions/6690752/insert-html-at-caret-in-a-contenteditable-div

use the insertNode method of the Range you obtain from the selection. In IE 9 you can use pasteHTML as you mentioned. Below is a.. frag.appendChild node range.insertNode frag Preserve the selection if lastNode range range.cloneRange range.setStartAfter lastNode.. sel.removeAllRanges sel.addRange range else if document.selection document.selection.type Control IE 9 document.selection.createRange..

JQuery: Selecting Text in an Element (akin to highlighting with your mouse)

http://stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse

range.select else if .browser.mozilla .browser.opera var selection window.getSelection var range document.createRange range.selectNodeContents.. range document.createRange range.selectNodeContents text selection.removeAllRanges selection.addRange range else if .browser.safari.. range.selectNodeContents text selection.removeAllRanges selection.addRange range else if .browser.safari var selection window.getSelection..

Jquery: Selection within a selection

http://stackoverflow.com/questions/1266604/jquery-selection-within-a-selection

Selection within a selection I have an array of different elements stored..

Web Page Source Annotation Tool

http://stackoverflow.com/questions/14244498/web-page-source-annotation-tool

shot Context Menu Appearance after selection of text 1 Selection context event fires when a selection of text is done by mouse.. with user defined tags HTML Code Before HTML Code After Selection Select a li text from output console of jsfiddle through context.. switch message Hanlde univ tag case univ if document.getSelection .baseNode null document.getSelection .baseNode.parentNode.innerHTML..

How do you select a particular option in a SELECT element in jQuery?

http://stackoverflow.com/questions/314636/how-do-you-select-a-particular-option-in-a-select-element-in-jquery

selected value DEFAULT Default option option value SEL1 Selection 1 option option value SEL2 Selection 2 option select div jquery.. option value SEL1 Selection 1 option option value SEL2 Selection 2 option select div jquery share improve this question .. option eq 1 ' For a known text '.selDiv option contains Selection 1 ' EDIT As commented above the OP might have been after changing..

Clear Text Selection with JavaScript

http://stackoverflow.com/questions/3169786/clear-text-selection-with-javascript

Text Selection with JavaScript Simple question which I can't find the answer.. jquery share improve this question if window.getSelection if window.getSelection .empty Chrome window.getSelection .empty.. this question if window.getSelection if window.getSelection .empty Chrome window.getSelection .empty else if window.getSelection..

Cross Browser Selection Range Library?

http://stackoverflow.com/questions/3454152/cross-browser-selection-range-library

Browser Selection Range Library Does any one know of any cross browser user selection.. off some of my tricks http plugins.jquery.com project wrapSelection http perplexed.co.uk 1020_text_selector_jquery_plugin.htm And.. templateElement var range sel rangy.getSelection var ranges sel.getAllRanges var textNodes textNode el i len..

jquery: select text event

http://stackoverflow.com/questions/4367353/jquery-select-text-event

Example document.onselectionchange function console.log Selection changed Here's a simple example function selectCallback selectionParentElement.. var mouseOrKeyUpHandler if typeof window.getSelection undefined Non IE mouseOrKeyUpHandler function var sel window.getSelection.. Non IE mouseOrKeyUpHandler function var sel window.getSelection if sel.rangeCount 0 var range sel.getRangeAt 0 if range.toString..

Validation of Invalid Date/ Leap Year

http://stackoverflow.com/questions/4852817/validation-of-invalid-date-leap-year

else return false script h2 style margin 0 padding 0 Date Selection h2 FORM method POST action php echo PHP_SELF select name mo..

Populating One Select Box Based on the Selection in Another Select Box - JQuery?

http://stackoverflow.com/questions/5861090/populating-one-select-box-based-on-the-selection-in-another-select-box-jquery

One Select Box Based on the Selection in Another Select Box JQuery I am trying to populate one select..

How to set caret(cursor) position in contenteditable element (div)?

http://stackoverflow.com/questions/6249095/how-to-set-caretcursor-position-in-contenteditable-element-div

this question In most browsers you need the Range and Selection objects. You specify each of the selection boundaries as a node.. editable var range document.createRange var sel window.getSelection range.setStart el.childNodes 2 5 range.collapse true sel.removeAllRanges..

Get parent element of a selected text

http://stackoverflow.com/questions/7215479/get-parent-element-of-a-selected-text

selected text in the page For example div class someparent Selection of this text should refer to the 'someparent' class. span class.. expand the example to deal with that case too function getSelectionParentElement var parentEl null sel if window.getSelection sel.. var parentEl null sel if window.getSelection sel window.getSelection if sel.rangeCount parentEl sel.getRangeAt..

jQuery Browser Compatability (IE)

http://stackoverflow.com/questions/7225849/jquery-browser-compatability-ie

'span.selection.text' .html ' br My Week ' selected_week ' Selection ' 'input.radio' .change function '.teambox' .find 'span.strike'.. 'span.selection.text' .html ' br My Week ' selected_week ' Selection ' '.pickbox' .css 'border' '1px dashed #FFFFFF' '.pickbox'.. 'span.selection.text' .html ' br My Week ' selected_week ' Selection ' 'input not checked ' .next 'span' .removeClass 'strike' 'input..

Does anyone know a DOM inspector javascript library or plugin?

http://stackoverflow.com/questions/742210/does-anyone-know-a-dom-inspector-javascript-library-or-plugin

3006 And this one also is fine DOM Mouse Over Element Selection and Isolation Which is very simple with few lines of code and..

How to get the pixel offset from the current caret position in an iframe with contentEditable

http://stackoverflow.com/questions/8456652/how-to-get-the-pixel-offset-from-the-current-caret-position-in-an-iframe-with-co

document.getElementById 'elm1_ifr' .contentWindow.getSelection .anchorOffset I can use this to calculate the left property.. using document.getElementById 'elm1_ifr' .contentWindow.getSelection .anchorNode.parentNode And using jQuery to get the offset but.. the screen which in my opinion should be provided by the Selection API but currently there is nothing in browsers to provide this...

how to build jqgrid context menu from top level toolbar

http://stackoverflow.com/questions/8457282/how-to-build-jqgrid-context-menu-from-top-level-toolbar

buttons icons and button titles become menu item titles. Selection menu triggers toolbar button click event. Or if this is not.. easy modify the code for multiselect true grid.jqGrid 'setSelection' rowId else if p.multiselect Edit will edit FIRST selected..

Why is jQuery so widely adopted versus other Javascript frameworks? [closed]

http://stackoverflow.com/questions/990077/why-is-jquery-so-widely-adopted-versus-other-javascript-frameworks

Feature wise both jQuery and MooTools allow for easy DOM Selection and Manipulation jQuery '#someContainer div class~ dialog '..

jQuery selector regular expressions

http://stackoverflow.com/questions/190253/jquery-selector-regular-expressions

selectors share improve this question James Padolsey created a wonderful filter that allows regex to be used for selection. Say you have the following div div class asdf Padolsey's regex filter can select it like so div regex class . sd. Also..

How to disable text selection using jQuery?

http://stackoverflow.com/questions/2700000/how-to-disable-text-selection-using-jquery

to disable text selection using jQuery Does jQuery or jQuery UI have any functionality to disable text selection for given document elements javascript.. to disable text selection using jQuery Does jQuery or jQuery UI have any functionality to disable text selection for given document elements javascript jquery jquery ui share improve this question In jQuery 1.8 this can be done..

Get Cursor Position within a Text Input field

http://stackoverflow.com/questions/2897155/get-cursor-position-within-a-text-input-field

range is 0 oField.value.length. function doGetCaretPosition oField Initialize var iCaretPos 0 IE Support if document.selection Set focus on the element oField.focus To get cursor position get empty selection range var oSel document.selection.createRange.. iCaretPos 0 IE Support if document.selection Set focus on the element oField.focus To get cursor position get empty selection range var oSel document.selection.createRange Move selection start to 0 position oSel.moveStart 'character' oField.value.length.. Set focus on the element oField.focus To get cursor position get empty selection range var oSel document.selection.createRange Move selection start to 0 position oSel.moveStart 'character' oField.value.length The caret position is selection..

$(this) selector and children?

http://stackoverflow.com/questions/306583/this-selector-and-children

this question The jQuery constructor accepts a 2nd parameter which can be used to override the context of the selection. jQuery img this Which is the same as jQuery this .find img If the imgs are direct descendants of the clicked element you..

Change CSS of selected text using Javascript

http://stackoverflow.com/questions/3223682/change-css-of-selected-text-using-javascript

SelText window.getSelection else if document.getSelection SelText document.getSelection else if document.selection SelText document.selection.createRange .text return SelText However when I created a similar function to change the CSS.. else if document.getSelection SelText document.getSelection else if document.selection SelText document.selection.createRange .text return SelText However when I created a similar function to change the CSS of the selected text using.. SelText window.getSelection else if document.getSelection SelText document.getSelection else if document.selection SelText document.selection.createRange .text SelText .css 'background color' 'yellow' 'font weight' 'bolder' Any ideas ..

jqGrid paging question

http://stackoverflow.com/questions/3807623/jqgrid-paging-question

jqgrid incorrect select drop down option values in edit box

http://stackoverflow.com/questions/4469650/jqgrid-incorrect-select-drop-down-option-values-in-edit-box

value statesOfCountry v dataEvents type 'change' fn function e To be able to save the results of the current selection the value of the column property must contain at least the current selected 'State'. So we have to reset the column..

Can the jQuery UI Datepicker be made to disable Saturdays and Sundays (and holidays)?

http://stackoverflow.com/questions/501943/can-the-jquery-ui-datepicker-be-made-to-disable-saturdays-and-sundays-and-holid

i 1 return false natDays i 2 '_day' return true '' One built in function exists called noWeekends that prevents the selection of weekend days. .selector .datepicker beforeShowDay .datepicker.noWeekends To combine the two you could do something like..

Browser Memory Usage Comparison: inline onClick vs. using JQuery .bind()

http://stackoverflow.com/questions/5303471/browser-memory-usage-comparison-inline-onclick-vs-using-jquery-bind

to use beforeSelectRow event. It's advantage is that if the user will click on one from your custom buttons the row selection can stay unchanged. With the onCellSelect the row will be first selected and then the onCellSelect event handler called... e.target if iCol firstButtonColumnIndex alert rowid rowid nButton name buttonNames iCol prevent row selection if one click on the button return iCol firstButtonColumnIndex false true where firstButtonColumnIndex 8 and buttonNames..

Insert html at caret in a contenteditable div

http://stackoverflow.com/questions/6690752/insert-html-at-caret-in-a-contenteditable-div

share improve this question In most browsers you can use the insertNode method of the Range you obtain from the selection. In IE 9 you can use pasteHTML as you mentioned. Below is a function to do this in all major browsers. If content is already.. node lastNode while node el.firstChild lastNode frag.appendChild node range.insertNode frag Preserve the selection if lastNode range range.cloneRange range.setStartAfter lastNode range.collapse true sel.removeAllRanges sel.addRange.. range.setStartAfter lastNode range.collapse true sel.removeAllRanges sel.addRange range else if document.selection document.selection.type Control IE 9 document.selection.createRange .pasteHTML html UPDATE 21 AUGUST 2013 As requested..

JQuery: Selecting Text in an Element (akin to highlighting with your mouse)

http://stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse

document.body.createTextRange range.moveToElementText text range.select else if .browser.mozilla .browser.opera var selection window.getSelection var range document.createRange range.selectNodeContents text selection.removeAllRanges selection.addRange.. .browser.opera var selection window.getSelection var range document.createRange range.selectNodeContents text selection.removeAllRanges selection.addRange range else if .browser.safari var selection window.getSelection selection.setBaseAndExtent.. selection window.getSelection var range document.createRange range.selectNodeContents text selection.removeAllRanges selection.addRange range else if .browser.safari var selection window.getSelection selection.setBaseAndExtent text 0 text 1 EDIT..

Jquery: Selection within a selection

http://stackoverflow.com/questions/1266604/jquery-selection-within-a-selection

Selection within a selection I have an array of different elements stored from a previous selection call it ' a '. How do i then..

Web Page Source Annotation Tool

http://stackoverflow.com/questions/14244498/web-page-source-annotation-tool

is activated when a selection is made as shown in this screen shot Context Menu Appearance after selection of text 1 Selection context event fires when a selection of text is done by mouse click Demonstration Look at jsfiddle after installation of.. jsfiddle after installation of chrome extension it annotates with user defined tags HTML Code Before HTML Code After Selection Select a li text from output console of jsfiddle through context menu added to chrome browser you can see DOM is also changed.. function message sender response switch message Hanlde univ tag case univ if document.getSelection .baseNode null document.getSelection .baseNode.parentNode.innerHTML univ document.getSelection .baseNode.parentNode.innerHTML..

How do you select a particular option in a SELECT element in jQuery?

http://stackoverflow.com/questions/314636/how-do-you-select-a-particular-option-in-a-select-element-in-jquery

Example markup div class selDiv select class opts option selected value DEFAULT Default option option value SEL1 Selection 1 option option value SEL2 Selection 2 option select div jquery share improve this question A selector to get the middle.. select class opts option selected value DEFAULT Default option option value SEL1 Selection 1 option option value SEL2 Selection 2 option select div jquery share improve this question A selector to get the middle option element by value is '.selDiv.. by value is '.selDiv option value SEL1 ' For an index '.selDiv option eq 1 ' For a known text '.selDiv option contains Selection 1 ' EDIT As commented above the OP might have been after changing the selected item of the dropdown. In version 1.6 and..

Clear Text Selection with JavaScript

http://stackoverflow.com/questions/3169786/clear-text-selection-with-javascript

Text Selection with JavaScript Simple question which I can't find the answer to how can I use JavaScript or jQuery to deselect any text.. How should I go about writing it Thanks for the help. javascript jquery share improve this question if window.getSelection if window.getSelection .empty Chrome window.getSelection .empty else if window.getSelection .removeAllRanges Firefox window.getSelection.. writing it Thanks for the help. javascript jquery share improve this question if window.getSelection if window.getSelection .empty Chrome window.getSelection .empty else if window.getSelection .removeAllRanges Firefox window.getSelection .removeAllRanges..

Cross Browser Selection Range Library?

http://stackoverflow.com/questions/3454152/cross-browser-selection-range-library

Browser Selection Range Library Does any one know of any cross browser user selection range libraries written in javascript I have found.. have already implemented and am using the following to pull off some of my tricks http plugins.jquery.com project wrapSelection http perplexed.co.uk 1020_text_selector_jquery_plugin.htm And a few other small scripts and such. I would just like to know.. nodes within a selection and surround each one function surroundSelectedText templateElement var range sel rangy.getSelection var ranges sel.getAllRanges var textNodes textNode el i len j jLen for i 0 len ranges.length i len i range ranges i If one..

jquery: select text event

http://stackoverflow.com/questions/4367353/jquery-select-text-event

of years. IE also supports this event back to version 5.5. Example document.onselectionchange function console.log Selection changed Here's a simple example function selectCallback selectionParentElement console.log Selecting parent element is selectionParentElement.nodeName.. console.log Selecting parent element is selectionParentElement.nodeName var mouseOrKeyUpHandler if typeof window.getSelection undefined Non IE mouseOrKeyUpHandler function var sel window.getSelection if sel.rangeCount 0 var range sel.getRangeAt.. var mouseOrKeyUpHandler if typeof window.getSelection undefined Non IE mouseOrKeyUpHandler function var sel window.getSelection if sel.rangeCount 0 var range sel.getRangeAt 0 if range.toString var selParentEl range.commonAncestorContainer if selParentEl.nodeType..

Validation of Invalid Date/ Leap Year

http://stackoverflow.com/questions/4852817/validation-of-invalid-date-leap-year

1 day date.getDate year date.getFullYear return true else return false script h2 style margin 0 padding 0 Date Selection h2 FORM method POST action php echo PHP_SELF select name mo id mo option disabled disabled SELECT MONTH option option January..

Populating One Select Box Based on the Selection in Another Select Box - JQuery?

http://stackoverflow.com/questions/5861090/populating-one-select-box-based-on-the-selection-in-another-select-box-jquery

One Select Box Based on the Selection in Another Select Box JQuery I am trying to populate one select box based on the selection made in the first select box...

How to set caret(cursor) position in contenteditable element (div)?

http://stackoverflow.com/questions/6249095/how-to-set-caretcursor-position-in-contenteditable-element-div

jquery contenteditable caret cursor position share improve this question In most browsers you need the Range and Selection objects. You specify each of the selection boundaries as a node and an offset within that node. For example to set the caret.. text you'd do the following var el document.getElementById editable var range document.createRange var sel window.getSelection range.setStart el.childNodes 2 5 range.collapse true sel.removeAllRanges sel.addRange range IE 9 works completely differently...

Get parent element of a selected text

http://stackoverflow.com/questions/7215479/get-parent-element-of-a-selected-text

text Is it possible to get the parent element of a selected text in the page For example div class someparent Selection of this text should refer to the 'someparent' class. span class spanparent If this is selected the parent should be this.. is only supported in Firefox. If this is important I can expand the example to deal with that case too function getSelectionParentElement var parentEl null sel if window.getSelection sel window.getSelection if sel.rangeCount parentEl sel.getRangeAt.. expand the example to deal with that case too function getSelectionParentElement var parentEl null sel if window.getSelection sel window.getSelection if sel.rangeCount parentEl sel.getRangeAt 0 .commonAncestorContainer if parentEl.nodeType 1 parentEl..

jQuery Browser Compatability (IE)

http://stackoverflow.com/questions/7225849/jquery-browser-compatability-ie

'table.weekbox' .hide 'table#weekbox' selected_week .show 'span.selection.text' .html ' br My Week ' selected_week ' Selection ' 'input.radio' .change function '.teambox' .find 'span.strike' .removeClass 'strike' var selected this .val var us_selected.. 'table.weekbox' .hide 'table#weekbox' selected_week .show 'span.selection.text' .html ' br My Week ' selected_week ' Selection ' '.pickbox' .css 'border' '1px dashed #FFFFFF' '.pickbox' .text '' 'table.weekbox' .hide 'table#weekbox' selected_week.. 'table.weekbox' .hide 'table#weekbox' selected_week .show 'span.selection.text' .html ' br My Week ' selected_week ' Selection ' 'input not checked ' .next 'span' .removeClass 'strike' 'input disabled not checked ' .next 'span' .addClass 'strike'..

Does anyone know a DOM inspector javascript library or plugin?

http://stackoverflow.com/questions/742210/does-anyone-know-a-dom-inspector-javascript-library-or-plugin

question I found this one http userscripts.org scripts review 3006 And this one also is fine DOM Mouse Over Element Selection and Isolation Which is very simple with few lines of code and give me something good to edit a little and get exactly what..

How to get the pixel offset from the current caret position in an iframe with contentEditable

http://stackoverflow.com/questions/8456652/how-to-get-the-pixel-offset-from-the-current-caret-position-in-an-iframe-with-co

for auto complete purposes . I know how to get the caret position document.getElementById 'elm1_ifr' .contentWindow.getSelection .anchorOffset I can use this to calculate the left property of the div but I can't seem to figure out how to get the top.. to get the top . Another possibility I thought about was using document.getElementById 'elm1_ifr' .contentWindow.getSelection .anchorNode.parentNode And using jQuery to get the offset but if that parent has a long text line I would only be able to..

how to build jqgrid context menu from top level toolbar

http://stackoverflow.com/questions/8457282/how-to-build-jqgrid-context-menu-from-top-level-toolbar

coding is not required Context menu should contain toolbar buttons icons and button titles become menu item titles. Selection menu triggers toolbar button click event. Or if this is not possible how to sync context menu items with toolbar Fox example.. is for multiselect false which we use but one can easy modify the code for multiselect true grid.jqGrid 'setSelection' rowId else if p.multiselect Edit will edit FIRST selected row. rowId is allready selected but can be not the last selected...

Why is jQuery so widely adopted versus other Javascript frameworks? [closed]

http://stackoverflow.com/questions/990077/why-is-jquery-so-widely-adopted-versus-other-javascript-frameworks

Manipulation but seem to be limited to helping you do that. Feature wise both jQuery and MooTools allow for easy DOM Selection and Manipulation jQuery '#someContainer div class~ dialog ' .css 'border' '2px solid red' .addClass 'critical' MooTools..