Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   конкатенация строки (https://javascript.ru/forum/misc/49008-konkatenaciya-stroki.html)

new_developer 25.07.2014 13:03

конкатенация строки
 
Всем привет, перепробовал все варианты которые на ум приходили, не ладится что-то со строками))

вообщем надо слеш добавить перед решёткой...

thisLink = $("a[href=+ '/' + #" + thisDestination.attr("id") + "]");


на такой вариант ругается

new_developer 25.07.2014 13:06

thisLink = $("a[href=+ "/" + #" + thisDestination.attr("id") + "]");


так выдает Uncaught Error: Syntax error, unrecognized expression: NaNp1]

Pavel M. 25.07.2014 13:15

может быть так?
thisLink = $("a[href=" + "/#" + thisDestination.attr("id") + "]");

new_developer 25.07.2014 13:27

Цитата:

Сообщение от Pavel M. (Сообщение 322713)
может быть так?
thisLink = $("a[href=" + "/#" + thisDestination.attr("id") + "]");

Uncaught Error: Syntax error, unrecognized expression: a[href=/#p1]

new_developer 25.07.2014 13:29

Сам скрипт, у меня у перед сыллками / чтобы с других страниц возврашался без слеша всё ок, а как его к этому выражению приделать не знаю)

//scroll

    var theDestinations = $('a[id]');

    theDestinations.each(function(i){

        var	thisDestination =  $(this),
            thisDestinationOffset = thisDestination.offset(),
            thisLink = $("a[href=" + "/#" + thisDestination.attr("id") + "]");

         


        if(thisLink.length > 0) {
            thisLink.click(function(){
                $('html,body').animate({scrollTop : thisDestinationOffset.top-70}, 1000);
                return false;
            });
        }
    });

tsigel 25.07.2014 13:29

thisLink = $("a[href='/#" + thisDestination.attr("id") + "']");

new_developer 25.07.2014 13:38

tsigel,
Спасибо

tsigel 25.07.2014 13:40

Пожалуйста :)


Часовой пояс GMT +3, время: 08:43.