Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm using expressionengine as a CMS, after the page is loaded, I need to find 'arbesthealth' and make it ar*best*health, What would be the best way to do this? Jquery after document ready? can it be done with CSS?
note: I can't do it on the cms side because EE doesn't allow tags inside the title fields so it needs to be done on output. I guess I could do it with a substr in php, but I'm just curious to the other ways that this would be possible.
The simple solution would be to manipulate innerHTML (directly, or through jQuery's html function), but that will destroy and recreate all of the elements, which isn't ideal — not least because any event handlers attached to them will get removed.
But a simple recursive function processing text nodes and inserting strong elements as necessary isn't difficult. My answer to this other SO question shows how to do that, walking through the text nodes and using Text#splitText to split them up and insert elements. Sounds like a lot more work than it is.
Wrap a tag inside the word like this:
$('.content').wrapInTag({
words: ['best'],
tag: '<span>'
});
See FIDDLE
I added in .content but you can add it wherever the cms has the container
*UPDATE*
As mentioned this will effect all so lets try this method:
html().replace
SPECIFIC FIDDLE
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
I am working on a small project for work and I came across a piece of code that is iterating a counter, and if that counter is not 0 then it executes this small bit of code:
if (cnt) jQuery('#none').prop('checked', false);
I am trying to understand what the jQuery('#none') selector is. When I execute it alone as just a selector within the chrome console, it returns an empty set. I have been googling for about 30 minutes, searching jQuery/JavaScript/CSS docs and all I can find are a few references to things where people are using this selector, but the topic in question is not in regard to the selector itself. To me this line appears to be doing literally nothing as commenting it out does not seem to change the behavior.
I really prefer to not mess around with stuff I don't understand as that almost always results in bugs. Can anyone point me to some documentation or just explain here what the #none selector is?
EDIT:
It would appear there is no magic #none selector. My assumption is this was left over from a previous iteration, it threw me off since the person who originally wrote it does not write erroneous code like this and I was finding people using the same selector online with no explanation - but those instances were red herrings.
jQuery('#none') selects all elements where id=none. If there are no elements with the id of "none", then it will return an empty set.
<div id=none>This div has the id = "none"</div>
It sounds like you found a piece of 'cruft' (aka zombie code).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
When I am try google custom search engine, I saw this tag in code.
What kind of tag is this?
When and how to use this kind of tag and why?
Thanks in advance.
Any tag of the form <X:Y> is a Y tag in the X namespace. In this case, the namespace is gcse, presumably "google custom search engine". Namespaces are useful when defining custom tags to help ensure they don't conflict with any others. Usually tags like this are manipulated by JavaScript, because the browser itself won't do anything special with them.
Even though it is highly unrecommended, you can implement your own html elements.
A good example of this is the html5shiv which provides html5 elements to legacy browsers:
nav
main
article
Now what Google are essentially doing the same, but with their own 'search' element.
Refer this link for details on <gcse:search>
https://developers.google.com/custom-search/docs/element
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I've been handed a role administering a SharePoint site, and the following custom code is on one of the pages:
<script type="text/javascript">
$(document).ready(function() {
$("#pgtitle").html("Customer Service Feedback");
});
</script
I'm not a javascript guy, so I'm having trouble interpreting this. The code was written by someone who is no longer with my firm, and left well before I arrived.
$(document).ready(function() means that the code that follows, will start as soon as the page has loaded.
$("#pgtitle").html("Customer Service Feedback"); simply passes the value Customer Service Feedback to the HTML element pgtitle.
if you look on the page for the pgtitle element, I'm sure you will see it contains the text Customer Service Feedback ! :)
It sets text on the element of id = pgtitle as soon as the DOM document had fully loaded. In human language it manually sets the value of some title.
Have a look at the JQuery library for the "html" method and if you look for the id that is called "pgtitle" you will find the html that is effected.
Source:http://api.jquery.com/html/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to create multiple choice filter. So there should be a div with content and other div's that u can click and toggle. For test purposes I just created something like that: jsfiddle my code
That is pretty what I want so going on - I can't write the same functionality but for toggling buttons (tw bootstrap) or other divs. I don't know how to modify that part $.map($(':checked') to properly create my chain of id's.
When I used tw bootstrap buttons I just tried to write something like: $.map($('.active') but it didn't work. So how to do to create that functionality but for that case with buttons from tw bootstrap?
Little edit: And how to do this using div's like buttons? I mean there will be some div's and jQuery creating class "active".
checkboxes with have that code: http://jsfiddle.net/eXhqu/
Everything is fine, except that filter() function is fired before bootstrap function. You can use setTimeout with 1ms delay.
Look at my version of code: http://jsfiddle.net/eFswC/1/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to use 2 different open source plugins for my website, a gallery and a calendar, both uses JQuery to work.
But when i put both of their javascript together in my website, it clashes and only one will be able to appear.
Is there any ways to specific if that javascript file just works for one DIV only? Or any work around to have both in my website.
Is there any ways to specific if that javascript file just works for one DIV only?
No, there is a single execution environment for a given HTML document. The only way to sandbox JavaScript is to put it in an iframe (even then, there are APIs that allow other documents to be affected)
Or any work around to have both in my website.
Edit the source of the respective scripts to change which elements they affect and to make them use the same version of jQuery and any other libraries they might depend on.