I want to select the text in a paragraph when I click or double click the <p>
tag. Not highlight, just like using mouse to make a select area to choose text to be selected!
I have several paragraph and *.rar file link addresses on the page, and I want to select all the text when I click on one of them. I think the textbox could work that way but I like it to be in a paragraph or link tag.
Is there a way to select all text in paragraph by clicking another element?
To select a block of text or a paragraph, click at one end of the block. Then, hold down the Shift key and click a second time at the opposite end of the block. You can also select and entire paragraph by triple clicking either the paragraph itself or from the margin by double-clicking the left mouse button.
To select a single word, quickly double-click that word. To select a line of text, place your cursor at the start of the line, and press Shift + down arrow. To select a paragraph, place your cursor at the start of the paragraph, and press Ctrl + Shift + down arrow.
Ctrl + A Select all contents of the page. Ctrl + B Bold highlighted selection. Ctrl + C Copy selected text. Ctrl + X Cut selected text. Ctrl + P Open the print window.
the problem “could be” the sticky keys are disabled. Try pressing repetitive and many times the same “Shift” key until a windows pop up with options to turn ON or OFF the Sticky Keys.
Here's a function that will select the contents of the element you pass to it:
function selectElementContents(el) {
var range;
if (window.getSelection && document.createRange) {
range = document.createRange();
var sel = window.getSelection();
range.selectNodeContents(el);
sel.removeAllRanges();
sel.addRange(range);
} else if (document.body && document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(el);
range.select();
}
}
window.onload = function() {
var el = document.getElementById("your_para_id");
selectElementContents(el);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With