Am i able to execute jQuery code in Target?

Avatar

Avatar
Validate 1
Level 3
stevemalko
Level 3

Likes

17 likes

Total Posts

27 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
stevemalko
Level 3

Likes

17 likes

Total Posts

27 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
stevemalko
Level 3

28-08-2019

is it possible to execute jQuery code from the custom code box within Target for specific experiences? The website has the jQuery library loaded already.

I am trying to do some simple things like $('body').hide(); commands, but no such luck. The end result is to use ajax

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 50
Employee
Shruthi_N
Employee

Likes

272 likes

Total Posts

236 posts

Correct reply

64 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Shruthi_N
Employee

Likes

272 likes

Total Posts

236 posts

Correct reply

64 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
Shruthi_N
Employee

28-08-2019

stevemalko​ Yes its possible to execute jQuery using the custom code section. The same has been documented at Modifications overview and there are samples provided as well in that document .

Hope this helps answer your question.

Answers (4)

Answers (4)

Avatar

Avatar
Validate 1
Level 3
stevemalko
Level 3

Likes

17 likes

Total Posts

27 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
stevemalko
Level 3

Likes

17 likes

Total Posts

27 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
stevemalko
Level 3

28-08-2019

Thanks. the mistake I was making was not wrapping it in a document.ready function. once I did that, everything worked, including ajax calls

Avatar

Avatar
Give Back 5
Level 3
skandg43264764
Level 3

Likes

31 likes

Total Posts

38 posts

Correct reply

7 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 5
View profile

Avatar
Give Back 5
Level 3
skandg43264764
Level 3

Likes

31 likes

Total Posts

38 posts

Correct reply

7 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 5
View profile
skandg43264764
Level 3

29-08-2019

Using custom code, you can almost do whatever we do on a HTML page so you can jquery or JavaScript code enclosed within a <script> tag.

Note: if you are using some functions of jquery then make sure the relevant jquery file is present on the page.

Are you loading jquery after target on the web page ?

Avatar

Avatar
Contributor
Level 3
johnanish
Level 3

Likes

27 likes

Total Posts

14 posts

Correct reply

0 solutions
Top badges earned
Contributor
Shape 1
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Contributor
Level 3
johnanish
Level 3

Likes

27 likes

Total Posts

14 posts

Correct reply

0 solutions
Top badges earned
Contributor
Shape 1
Give Back 5
Give Back 3
Give Back
View profile
johnanish
Level 3

28-08-2019

Thats pretty much what I would have done as well. Check if jQuery was "ready".

Avatar

Avatar
Give Back 50
Employee
Shruthi_N
Employee

Likes

272 likes

Total Posts

236 posts

Correct reply

64 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Shruthi_N
Employee

Likes

272 likes

Total Posts

236 posts

Correct reply

64 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
Shruthi_N
Employee

28-08-2019

Awesome. Thanks for that quick confirmation.