Created
October 31, 2016 11:04
-
-
Save alex-boom/819f38975724e7b02544b92faf826158 to your computer and use it in GitHub Desktop.
do one line content for atributes title and alt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Разбивает текст тайтла на два тега, оставляя в тайтле начало строки до найденного маяка /alt/ и забирает текст | |
//от маяка /alt/ в тег alt. | |
var $this = $(".portfolio-detail-inner a"); | |
$.each( $this, function () { | |
var str = $(this).attr("title"); | |
var search = str.search(/alt/); | |
var gettingStr = function() { | |
if (search > 0 ) { | |
var from = search; | |
var to = str.length; | |
var $newstr = str.substring(from,to); | |
return $newstr; | |
} else { | |
console.log(''); | |
} | |
}; | |
var textAlt = function() { | |
var from = 4; | |
var to = gettingStr().length; | |
var newstr = gettingStr().substring(from,to); | |
return newstr; | |
}; | |
var textTitle = function() { | |
if (search > 0 ) { | |
var from = search; | |
var to = 0; | |
var $newstr = str.substring(from,to); | |
return $newstr; | |
} else { | |
console.log(''); | |
} | |
}; | |
$(this).attr("title", textTitle); | |
$(this).find("img").attr("alt", textAlt); | |
$(this).find("span").text(""); | |
//do one line content for atributes title and alt | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment