w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Find part of string throughout site and replace with new text
Yes, but it won't be efficient if you tell jQuery to search the entire document. To make it efficient, you'll need to have jQuery get a specific location to search if you want any efficiency in it.

Categories : Javascript

How to replace part of a text using regular expression in JavaScript?
This pattern: /[^&]{0,}/ is gobbling up everything that is not a & character, which is why it extends beyond the URL itself. Instead, since you know that the width and height are numbers, you can just match on digits: .replace(/width=d*/gi,'width=300') .replace(/&height=d*|height=d*&?/gi,''); The  is a zero-width match to a word boundary, so that if you have framewidth=500 for example it won't be affected. The 2 matches to height are so that it won't replace both &'s if they are on each side. E.g. you don't want '?width=500&height=500&cache=123' to turn into '?width=300cache=123' for instance.

Categories : Javascript

How to find and replace part of a cell with formatted text
Maybe this would suit (be sure to select no more cells than necessary before running or this could take a while): Sub FormatSelection() Dim cl As Range Dim SearchText As String Dim StartPos As Integer Dim EndPos As Integer Dim TestPos As Integer Dim TotalLen As Integer On Error Resume Next Application.DisplayAlerts = False SearchText = Application.InputBox _ (Prompt:="Enter string.", Title:="Which string to format?", Type:=2) On Error GoTo 0 Application.DisplayAlerts = True If SearchText = "" Then Exit Sub Else For Each cl In Selection TotalLen = Len(SearchText) StartPos = InStr(cl, SearchText) TestPos = 0 Do While StartPos > TestPos With cl.Characters(StartPos, TotalLen).Font .FontStyle = "Bold" .ColorIndex = 3 End With EndPos = StartPos + TotalLen

Categories : Excel

Change part of href url link via javascript or Jquery
I am not sure this might work but just try it. You can set a value of any html attribute by using the .attr() function. So you might write: $('.linkClass').attr('src', 'the new value of the src'); Hope it helps.

Categories : Jquery

jQuery text() with replace() doesn't replace the text
Use this instead : $('#resetPWSuccess').text( $('#resetPWSuccess').text().replace('*|RESETPASSWORDEMAIL|*', emailAddress) ).show(); Note that I also removed the h2 from your selector : it's useless and slower than just using the id. When you ask jQuery to search for #resetPWSuccess, it uses the very fast native getElementById function. From jQuery's source code : // Shortcuts if ( (match = rquickExpr.exec( selector )) ) { // Speed-up: Sizzle("#ID") if ( (m = match[1]) ) { if ( nodeType === 9 ) { elem = context.getElementById( m );

Categories : Jquery

How to replace a href link within a Textarea with jQuery
This is an example; after loading the href will get replaced: <!DOCTYPE html> <html> <head> <script> window.onload = function () { var textarea = document.getElementsByTagName("textarea")[0]; textarea.innerHTML = textarea.innerHTML.replace( /href=".*"/, "http://www.stackoverflow.com"); } </script> </head> <body> <textarea><a href="http://www.google.com"></a></textarea> </body> </html>

Categories : Javascript

jQuery replace text when clicking over different input text objects
Change your javascript to something like this: $('#titleClick').on('focus', function(){ $('#text').remove(); $("#title").append('<span id="text" style="font-weight: bold; font-size: 18px; color: red;">Title text</span>'); }); $('#descriptionClick').on('focus', function(){ $('#text').remove(); $("#description").append('<span id="text" style="float:left; font-weight: bold; font-size: 18px; color: red;"> Description text</span>'); });

Categories : Javascript

Search and replace within a text field to remove part of field
There is no native function to that. You might use a User Defined Function - take a look here: https://launchpad.net/mysql-udf-regexp You could also consider using an ETL framework for that (such as Clvoer ETL Framework - http://www.cloveretl.com/).

Categories : Mysql

jQuery wrap list elements containing the same text part
Try this, $("#getStyles .lv3").each(function() { txt=$(this).text().split(' ')[0]; if(!$('#result').find('.'+txt).length) { $('#result').append('<ul class="'+txt+'"><li class="lvl2">'+txt+'</li></ul>'); } $('#result').find('.'+txt).append($(this)); }); Working Fiddle

Categories : Jquery

Replace text with my own - jQuery
$('firstQuestion').innerhtml(''); //WRONG and missed # for id selectors $('#firstQuestion').innerHTML(''); //Correct You can use .text()/.html() in jQuery $('#firstQuestion').html(''); $('#firstQuestion').html('MY QUESTION');

Categories : Jquery

Replace Log In text to say Logged in with jquery
If you're using jQuery you can call the following once you've successfully logged in. $('a#login.open').text('Logged In'); This is if you're trying to be super specific about the element you're searching for. If you are using chrome or anything other than IE you can try this out in the console debugger window to see that it works.

Categories : Javascript

jQuery how to remove or replace text after last
This would be the correct regexp to do it: var myString = "ex)OUTsoundfile.123054236.123054236.wav"; var output = myString.replace(/.[^.]*$/, ''); http://jsfiddle.net/samliew/3UdLH/

Categories : Jquery

Replace text with images in jQuery script
Try using this: $('#about, #subscribe, #contact').hide(); $('.home').click(function () { var id = this.id.replace('show_', ''); // this line has been changed var $content = $('#' + id + ':not(:visible)'); if ($('.current').length === 0) { showContent($content) } else { $('.current').fadeOut(600, function () { showContent($content) }); } }); function showContent(content) { content.fadeIn(600); $('.current').removeClass('current'); content.addClass('current'); } When you click on a link it takes the link's id then removes show_ and shows the div with that id. Here's an example: A user clicks the top link. The id is show_about. The javascript removes show_ leaving about then selects $('#about:not(:visible)'); and fad

Categories : Javascript

jQuery to replace Flash slideshow with text
Firstly, I would strongly recommend using TweenMax to recreate any Javascript animations that you want to imitate from flash. This is because TweenMax was created in Actionscript first. It follows a familiar api so should you encounter tweens in flash you will be able to get a good approximation in JS. Have a look: http://www.greensock.com/get-started-js/

Categories : Jquery

Problems with jquery - replace a too long text with "..."
Why not just use CSS? .test { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } Demo

Categories : Jquery

How to change text on a page? (Find and replace using jQuery?)
It it's always a textNode that is the first child of the parent div, you can do : var node = document.getElementById('v65-onepage-ordercomments-value').firstChild; node.nodeValue = 'new content'; FIDDLE or in jQuery: $('#v65-onepage-ordercomments-value').contents().each(function() { if (this.nodeType===3 && this.nodeValue.trim().length) this.nodeValue = 'new content'; }); FIDDLE

Categories : Javascript

JQuery autocomplete : Preventing text replace when focus
focus: function (event, ui) { event.preventDefault(); } Try this. This will not change your value on focus! Please note your-input-field-id is the id of your input field.

Categories : Jquery

how can I find id in text to make a link in jquery?
Change your code, you're missing quotes. $('#aaa').click (function(){ console.log('aaa'); }); check JSFiddle

Categories : Jquery

delay a $link.text after a fade out (jquery)
Put it inside the fadeToggle callback, so that it appears after the animation is completed. Plus if you are storing is Expanded just for swapping the text value you don't need it. You can instead use .text() callback function to return the value based on current text. $(document).ready(function () { $('.content').after('<a href="#" class="toggle-link">[Read More]</a>'); $(".content").hide(); $('.toggle-link').click(function (e) { e.preventDefault(); var $link = $(this); $link.prev(".content").fadeToggle(1000, function () { //Do it here var isExpanded = $link.data('expanded'); //Get the expanded value $link.text(function (_, text) { //use .text() function to switch value return text == "[Read More]" ?

Categories : Jquery

separate chinese part and english part from a text document
You can do with regex, the part that validate the pattern with alphabetic english character go to a part, and the part that dont validate to the other part. I supose that the two parts are in different parts (not mixing both partd), perhaps if they are mixed you could have the problem of the common characters (, . ? etc...), perhaps for this characters you could see the before and the next character. I think that this can be a possibility probably there are best ways to do that. Edit: I supose that is a txt, but in another format only pass to txt before.

Categories : Java

JQuery find child element inner text and replace with IMG HTML
You have typo in this line $('div.DetailRow')each(function(){ and then you can use jQuery .text() and .html() to check value and update. Try: $('div.DetailRow').find("div").each(function(){ if($(this).text().indexOf("in stock")!=-1){ $(this).text(""); $(this).html(instock); }else if($(this).text().indexOf("low stock")!=-1){ $(this).text(""); $(this).html(lowstock); }else{ $(this).text(""); $(this).html(nostock); } }); DEMO FIDDLE NOTE: Updated code to find div inside div.DetailsRow. Change it according to your requirement.

Categories : Javascript

How to replace text in first TD based on the values of table stored in other TD with JQuery?
Try: $('td:contains("N/A")').each(function () { if ($(this).children().length == 0) { $(this).closest('table').find('td').first().text($(this).closest('table').find('td').first().text().replace(/(.*)/ig, '()')); } }); jsFiddle example

Categories : Jquery

Remove extra link text after pageload in jQuery?
This should do it: var link = $('.cl_action_tag_wrapper > a'); var href = link.attr('href'); var index = href.indexOf('work/employ/'); href=href.substring(0,index>0? index+12:index); //+12 because work/employ/ is 12 chars link.attr('href',href); Fiddle here.

Categories : Jquery

jQuery fade in/out replaced text removes link
Well, you are using $(this).text(...) - this replaces the entire content of the element referred to by this - which is your h1 element. Instead, you should attach the code to your a element inside the h1: $('#heroburrito .vert h1 a.homehover').hover(...) This is correct in your question, but your fiddle only contained $('#heroburrito .vert h1').hover(...) thus replacing your entire link with the plain text. Here's my updated fiddle that works correctly. EDIT: if you need to run the fade in/out on h1 instead of the link itself, then you need to apply the text change to the link - here's an updated fiddle: $('#heroburrito .vert h1').hover(function () { $(this).fadeOut(200, function () { $('a.homehover', this).text('←retreat'); $(this).fadeIn().addClass('home')

Categories : Javascript

Jquery: Link text color to random background image
Why not update your images array so that each element is actually an array of `background/text-color' - like this: var images = [['1.jpg', '#000'], ['2.jpg', '#111'], ['3.jpg', '#222'], ['4.jpg', '#333'], ['5.jpg', '#444'], ['6.jpg', '#555']]; var random = Math.floor(Math.random() * images.length)] $(body).css({ 'background-image': 'url(img/' + images[random][0] + ')', 'color': images[random][1] });

Categories : Jquery

Sublime text find and replace with regex to convert jquery live() event to on()
You can use jQuery migrate. Include it after the core jquery file. This way you will not see any errors like Uncaught TypeError: Object [object Object] has no method 'live' http://code.jquery.com/jquery-migrate-1.2.0.js

Categories : Javascript

Image Link replace with other link JS
Iterate over all the images (by tag name) instead of getting the image by id. I'll also note that each DOM element id should be unique; you cannot assign the same id to more than one image. <script type="text/javascript"> $(document).ready(function(){ var images = document.getElementsByTagName('img'); for (var i = 0; i < images.length; ++i) { var orgImg = images[i]; orgImg.src = orgImg.src.replace('s512-c', 's36-c'); } })(); </script> If your page has more images on it than need to be modified, you might want to assign a class to the ones that do and use document.getElementsByClassName instead.

Categories : Javascript

JQuery Replace "Special" Function (like replace(/#[^#]*$/, "") replace(/?[^?]*$/, ""))
They are called regular expressions. Regular expressions are patterns used to match character combinations in strings

Categories : Jquery

replace part of string php
I think that what you really need is: An xml parser to parse your string and get the <body> section. See this question for more information; htmlspecialchars() for the result. Edit: If you know exactly what the html looks like, you can of course also explode on </head> or <body> to split your input in two, but that would be highly dependant on the exact format of the input so I would not recommend it.

Categories : PHP

Using replace to select part of a URL
First Part like case (1) and (2) var s = '//url.com/_t_522121?location=50457347'; var n = s.lastIndexOf('/'); var result = s.substring(n + 1); alert(result); n = result.indexOf('?'); result = result.substring(0, n); alert(result);

Categories : Javascript

How to replace part of the path?
Path class may help (at least in splitting file name from path and combining back), but you may need to do some string manipulations yourself too to replace particular component of the path.

Categories : C#

Replace a certain part of the date
Just remove the erroneous select: update Tablename set column = REPLACE(column, substring(column,1,5) from Tablename ,'01/01'); However, it seems like a more appropriate approach would be using the DATEPART function: UPDATE Tablename SET column = CAST('01/01/' + CAST(DATEPART(year, column) AS VARCHAR) AS DATETIME)

Categories : SQL

how to replace this part of string - •
String.replace does not work like that. If you pass in a string as the first parameter, it replaces instances of the string as a whole. Obviously this will do nothing unless all those characters appear one after another in the exact same order in your input. The correct syntax to replace all instances of certain characters is using a regular expression: str.replace(/[•]/g, '-');

Categories : Jquery

Replace DIV inside another DIV with TEXTAREA, edit text and replace back
You can try like this example javascript: $("#edit").live("click",function(){ $(".inputbox").val($("#menu").text()).show(); $("#menu").hide(); $("#save").show(); $(this).hide(); }); $("#save").live("click",function(){ $("#menu").show(); $("#menu b").html($(".inputbox").val()); $(".inputbox").hide(); $("#edit").show(); $(this).hide(); });

Categories : Jquery

Replace part of a line containing tabs
The error message Unknow option for command 's' (s///?) refers to the "options" that can be added to the substitute command after the third slash. These options include letters like g to replace all occurrences of the pattern rather than just the first one, or i to ignore letter case. It usually hints that the pattern or substitution includes extra slashes. To deal with slashes in the pattern or the substitution they have to be escaped, too: ACTUAL_VERSION=" <property name="systemVersionDsvTes" value="4.1.9"/>" NEW_VERSION=" <property name="systemVersionDsvTes" value="4.1.10"/>" Alternatively you can use a different character instead of a slash as the separator, for example #: sed -i -e "s#$ACTUAL_VERSION#$NEW_VERSION#g" buildSIM.xml

Categories : Regex

How to replace part of a string in MySQL?
I usually rename the returned value as a new field, in this case phone_replaced: SELECT REPLACE(`phone`, 'Phone: ', '') as `phone_replaced` FROM `events` But you can also keep the current name phone: SELECT REPLACE(`phone`, 'Phone: ', '') as `phone` FROM `events` As long as you alias it using as.

Categories : PHP

SQL: Replace Part Of a String in a Column for every row
I figured it out.. thanks to anyone who tried to help. First I had a few things wrong. For those who want to learn Since I already have a while@@ fetch i don't really need the loop BEGIN declare @subname varchar(70),@name1 varchar(50),@name varchar(50),@ID char(4), @location char(2) declare @pkey int,@IDLocation varchar(6) set @IDLocation='' set @name1='' DECLARE _cursor cursor for select pkey,name,ID,location from Table OPEN _cursor FETCH _cursor into @pkey, @name, @ID, @location while @@FETCH_STATUS = 0 Begin set @IDLocation = @ID+'-'+@location Select @subname= SUBSTRING(@name,1,CHARINDEX('-',@name)-1) set @name1= @subname+'-'+ @IDLocation Update Table set name=@name1 where pkey=@pkey Fetch _cursor into @pkey, @name, @ID, @location End close _

Categories : Sql Server

Use a function or Expression to replace the "new {x.ID,x.Name}" part
You could define a helper class like this to allow you to specify only some of the generic type parameters when creating a Func<T, R>: public static class Funk<T> { public static Func<T, R> Make<R>(Func<T, R> func) { return func; } } And use it like this: var selector = Funk<SomeTableName>.Make(x => new {x.ID, x.Name}); var result = db.SomeTable.Where(x => x.ID>1).Select(selector); This takes advantage of type inference to determine the return type, so you only have to define the input type (SomeTableName). The var keyword makes the selector variable implicitly typed, you won't have to specify Func<SomeTableName, _AnonymousType1_>. You can now reuse selector in multiple queries. You will not be able to save this

Categories : C#

Replace part of a string using regex in VB.NET
You could just do this: Dim nameEnd as String = namePara.Remove(namePara.Length - 3) & "END" But if you must use Regex: Dim nameEnd as String = Regex.Replace(namePara, "STA$", "END")

Categories : Regex

Replace a part of a varchar2 column in Oracle
To accomplish this, you can either use character functions such as substr(), replace() or a regular expression function - regexp_replace() for instance. SQL> with t1(col) as( 2 select 'TEMPORARY-2 TIME ECS BOUND -04-Insuficient Balance' 3 from dual 4 ) 5 select concat(substr( col, 1, 11), ' X') as res_1 6 , regexp_replace(col, '^(w+-d+)(.*)', '1 X') as res_2 7 from t1 8 ; Result: RES_1 RES_2 ------------- ------------- TEMPORARY-2 X TEMPORARY-2 X So your update statement may look like this: update your_table t set t.col_name = regexp_replace(col_name, '^(w+-d+)(.*)', '1 X') -- where clause if needed.

Categories : Regex



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.