Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

pass parameter inside jQuery Function

I want to pass "this" to "success" function i have tried to put "this" keyword as parameter inside brackets of success function..how to pass this key word inside success function? ... but it did not work...may be my english language not good ..sorry for that.

<script>
 $(document).ready(function () {
 $(".join").click(
 function () {
 if ($(this).text() == "join")
 {
 var FollowOptions = {};
 @*FollowOptions.url = "/@CultureInfo.CurrentCulture.Name/Communities/Follow/";*@
 FollowOptions.url = "/@CultureInfo.CurrentCulture.Name/Groups/Join/";
 FollowOptions.data = { id: $(this).attr("name") };
 FollowOptions.success = function (this) {
 $(this).prop("text", "leave");
 $(this).removeClass("btn btn-info");
 $(this).addClass("btn btn-danger");
 };
 $.ajax(FollowOptions);
 }
 else
 {
 var FollowOptions = {};
 FollowOptions.url = "/@CultureInfo.CurrentCulture.Name/Groups/UnJoin/";
 FollowOptions.data = { id: $(this).attr("name") };
 FollowOptions.success = function (this) {
 $(this).prop("text", "join");
 $(this).removeClass("btn btn-danger");
 $(this).addClass("btn btn-info");
 };
 $.ajax(FollowOptions);
 }
 });
 });
</script>

Answer*

Draft saved
Draft discarded
Cancel
2
  • thanks for your contribution ... but it does not work Commented Dec 15, 2019 at 19:10
  • @محمدالعاني I just edited the code, please try again to see if it works for you. Commented Dec 15, 2019 at 19:18

lang-js

AltStyle によって変換されたページ (->オリジナル) /